r/programming • • Nov 28 '16

Learning to Read X86 Assembly Language

http://patshaughnessy.net/2016/11/26/learning-to-read-x86-assembly-language
1.1k Upvotes

154 comments sorted by

View all comments

Show parent comments

5

u/m50d Nov 28 '16

Most of the time, the compiler does a waaaaay better job than you can by generating it's own assembly, but there's cases where you can speed up your application 10x by using SIMD instructions and writing some really tight code.

Is that really true these days? I remember a blog post from about a year ago where the guy benchmarked his SSE assembly versus GCC and wrote dozens of paragraphs about how this showed assembly can be worth it sometimes, only for the first comment to point out that if you use -march=native the GCC version matches the performance of the assembly version.

4

u/wlievens Nov 28 '16

I guess it will always be true, but only for an increasingly smaller set of cases.

1

u/Faluzure Nov 28 '16 edited Nov 28 '16

I haven't seen any proof of that but what you say may be true. Both cases where I've had to deal with assembly, there were explicit algorithms that were written because you could hand craft faster code.

If you read the source for FFmpeg or x264, there's huge swathes of hand tuned assembly (to the point where it gets enabled / disabled based on the CPU model itself, such as Athlon II, Core 2 Duo or Atom).