3 ms·
Back in the late 80s/early 90s, I did a lot of assembly language programming---6809, 68000, 8088 and MIPS, so it's not unfamiliar to me. I haven't really done
by spc476 9y ago
Back in the late 80s/early 90s, I did a lot of assembly language programming---6809, 68000, 8088 and MIPS, so it's not unfamiliar to me. I haven't really done any assembly language programming since ... eh ... 1995, so okay, I could be a bit rusty.
Anyway, a few weeks ago, I picked up one of the projects I worked in the early 90s, a mildly math heavy program that dealt with a pair of functions that I thought could easily be vectorized and oh! The Pentiums of today have vector instructions, and in reading over the programming manual, yes, it looked like it would be straightforward to write some vector code, in assembly (something I haven't done---should be fun).
My code easily beat clang (using C code) on its highest optimization setting. Easily beat, but it got pretty close. GCC? It (again, using the C version of the code) was smoking my code at -O2 by an embarrassing amount. And it wasn't even using the vectorized instructions! And to make sure, I ran the code on several different systems, so I don't think it was this version of the Pentium having a bad MMX implementation over that Pentium.
I haven't taken the time to figure out what GCC did (perhaps it knows better how to schedule MMX code than I do) as I was doing this for fun, not profit. All the data I was working with was in registers in my code.