Linked by ebasconp on Fri 10th Jun 2011 22:22 UTC
Permalink for comment 477166
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.
Features
Linked by Thom Holwerda on 05/24/13 17:26 UTC
Linked by Thom Holwerda on 05/21/13 21:38 UTC
Linked by Thom Holwerda on 05/20/13 11:29 UTC
Linked by Thom Holwerda on 05/18/13 21:33 UTC
Linked by David Adams on 05/16/13 4:23 UTC
Linked by Thom Holwerda on 05/11/13 21:41 UTC
Linked by Thom Holwerda on 05/08/13 14:22 UTC
Linked by Thom Holwerda on 05/02/13 15:28 UTC
Linked by Thom Holwerda on 04/29/13 21:06 UTC
Linked by Thom Holwerda on 04/24/13 22:24 UTC
More Features »
Sponsored Links



Member since:
2011-01-28
Carewolf,
"I also rarely see GCC vectorizing integer loops (it seems to choke on signed vs unsigned), GCC does slightly better with floating-point loops, and it helps if you allow it to break some strict math rules."
Really? I'd be surprised if signed vs unsigned was the reason it chokes. In two's complement, the calculation is identical regardless of sign.
0x43 + 0xfe (this is -2) = 0x41 (+carry flag)
0x43 - 2 = 0x41
0xf0 (this is -0x10) + 0xfd (this is -0x3) = 0xed (this is -0x13) (+carry flag)
0xfe (this is -2) * 0xfb (this is -5) = 0x0a (0xf9 carry)
In other words, GCC doesn't even have to care whether a variable is signed or unsigned in order to do "+ - *".
unsigned int x=-2;
unsigned int y=-10;
unsigned int z=49;
printf("%d\n", x*y*z); // give us 980
GCC merely ignores the carry (this is another one of my optimization gripes in fact, assembly programmers can use the carry flag, C programmers have to do computations using the next larger word size, sometimes wasting a register).
"If you compile to AMD64, SSE is automatically used for all math (not vectorized, one value at a time). You can also use SSE for math in IA32 using -mfpmath=sse. SSE math is generally much faster but removes the 80bit temporaries quirk 487 math has."
Yes, it's good to get away from quirky FP design.
Edit:
This C/assembly debate seems to come up all the time, the next time it does, I might just sit it out. It takes so much time to make the case, and at the end it's totally inconsequential.
Edited 2011-06-14 10:15 UTC