Compiler also generates code for avx2 even if I don't ask for it:
#include <stdio.h>
#define FOO 1000
double
todouble(void) {
return (double)FOO;
}
int
main(int argc, char** argv) {
printf("cvt doubel -> size_t\n");
printf("%lld\n", (size_t)todouble());
printf("Done!\n");
}
Compiled with:
cc -c -std:C11 -Ze -Zx -Gz -W1 -Go -Tx64-coff -Ob1 foo.c
It uses vcvttsd2si which makes generated code hand at runtime:
/usr/jullien/openlisp/src$ objdump.exe -d foo.obj
foo.obj: file format pe-x86-64
Disassembly of section .text:
0000000000000000 <todouble>:
0: f2 0f 10 05 00 00 00 movsd 0x0(%rip),%xmm0 # 8 <todouble+0x8>
7: 00
8: c3 retq
9: c3 retq
000000000000000a <main>:
a: 48 83 ec 28 sub $0x28,%rsp
e: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # 15 <main+0xb>
15: e8 00 00 00 00 callq 1a <main+0x10>
1a: e8 e1 ff ff ff callq 0 <todouble>
1f: f2 0f 10 25 00 00 00 movsd 0x0(%rip),%xmm4 # 27 <main+0x1d>
26: 00
27: 66 0f 2f c4 comisd %xmm4,%xmm0
2b: c4 e1 fb 2c d0 vcvttsd2si %xmm0,%rdx
30: 72 1e jb 50 <main+0x46>
32: f2 0f 10 e0 movsd %xmm0,%xmm4
36: f2 0f 5c 25 00 00 00 subsd 0x0(%rip),%xmm4 # 3e <main+0x34>
3d: 00
3e: 49 ba 00 00 00 00 00 movabs $0x8000000000000000,%r10
45: 00 00 80
48: c4 e1 fb 2c d4 vcvttsd2si %xmm4,%rdx
4d: 4c 31 d2 xor %r10,%rdx
50: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # 57 <main+0x4d>
57: e8 00 00 00 00 callq 5c <main+0x52>
5c: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # 63 <main+0x59>
63: e8 00 00 00 00 callq 68 <main+0x5e>
68: b8 00 00 00 00 mov $0x0,%eax
6d: 48 83 c4 28 add $0x28,%rsp
71: c3 retq