Unintentional use of SSE
gaul opened this issue · comments
Andrew Gaul commented
Some code unintentionally uses SSE:
unsigned int fp_func(unsigned int x) { return x * 0.8; }
unsigned int int_func(unsigned int x) { return x * 10 / 8; }
The integer version is shorter and more efficient:
$ gcc -O2 -S -o - foo.c | as -al
...
9 0000 89FF movl %edi,%edi
10 0002 660FEFC0 pxor %xmm0,%xmm0
11 0006 F2480F2A cvtsi2sdq %rdi,%xmm0
11 C7
12 000b F20F5905 mulsd .LC0(%rip),%xmm0
12 00000000
13 0013 F2480F2C cvttsd2siq %xmm0,%rax
13 C0
14 0018 C3 ret
...
24 0020 8D04BF leal (%rdi,%rdi,4),%eax
25 0023 01C0 addl %eax,%eax
26 0025 C1E803 shrl $3,%eax
27 0028 C3 ret
...
33 .LC0:
34 0000 9A999999 .long -1717986918
35 0004 9999E93F .long 1072273817