Issue
I have a C program that must run only on Ivy Bridge CPU where I'm compiling the code, on gcc 4.8 I have tried to compile using -march=native
to take advantage of all specific instruction of the CPU.
I want to compile this also in 32-bit mode for some research comparisons
I have compiled the program in this way for x64 (note I'm on Linux x64)
gcc -march=native -s -O2 mycode.c
and disassembling the code, I can see that AVX instruction set is used
And in this way for 32-bit x86
gcc -m32 -march=native -s -O2 mycode.c
If I try to disassemble the code I don't see any AVX instruction, and the instruction set is Pentium Pro, 80x87. Like fld
/ fadd
/ fstp
for FP math. Adding -mavx
doesn't help, same result.
How could I fix this?
Solution
From the GCC 4.8.3 manual:
-m32 -m64 -mx32
Generate code for a 32-bit or 64-bit environment. The -m32 option sets int, long, and pointer types to 32 bits, and generates code that runs on any i386 system. The -m64 option sets int to 32 bits and long and pointer types to 64 bits, and generates code for the x86-64 architecture. For Darwin only the -m64 option also turns off the -fno-pic and -mdynamic-no-pic options.
The -mx32 option sets int, long, and pointer types to 32 bits, and generates code for the x86-64 architecture.
The closest you're going to get to -m32
with AVX instructions is using -mx32
in it's place , but it might not be what you want.
Answered By - ldav1s