c - 让 GCC 在 32 位代码 (-m32) 中使用 AVX?

标签 c linux gcc compiler-optimization avx

我有一个 C 程序只能在我编译代码的 Ivy Bridge CPU 上运行,在 gcc 4.8 上我尝试使用 -march=native 编译以利用所有特定的CPU 的指令。 我也想在 32 位模式下编译它以进行一些研究比较

我已经以这种方式为 x64 编译了程序(注意我在 Linux x64 上)

gcc -march=native -s -O2 mycode.c

反汇编代码,我可以看到使用了AVX指令集

对于 32 位 x86 也是这样

gcc -m32 -march=native -s -O2 mycode.c

如果我尝试反汇编代码,我看不到任何 AVX 指令,指令集是 Pentium Pro,80x87。像 fld/fadd/fstp 用于 FP 数学。添加 -mavx 没有帮助,结果相同。

我该如何解决这个问题?

最佳答案

来自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.

使用 AVX 指令最接近 -m32 的方法是在原处使用 -mx32,但这可能不是您想要的。

关于c - 让 GCC 在 32 位代码 (-m32) 中使用 AVX?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24041752/

相关文章:

c - .bss 部分没有零初始化怎么样

linux - 如果不是 gcc -static 那么 shell 说 'no such file'

c - 在C中的双向链表中删除头节点的问题

c - 我不想回到产生中断的那一行

linux - 在日志文件中保留 60 行

c - GCC -nostdlib 失败, undefined reference `__libc_csu_fini'

c++ - 是否可以将 GTK+ 与 C++ 一起使用?

c - 在 Linux 上获取有关网络接口(interface)更改的通知

c++ - VTK:高度场的基本可视化

linux - 堆栈内存在 Linux 中物理上是连续的吗?