clang produces AVX instructions when generating code for arch that doesn't support them
| Bugzilla Link | 22693 |
| Resolution | WORKSFORME |
| Resolved on | Sep 01, 2021 17:08 |
| Version | 3.5 |
| OS | Linux |
| Attachments | test case |
| Reporter | LLVM Bugzilla Contributor |
| CC | @delena,@RKSimon,@nico,@rnk,@rotateright |
Extended Description
Problem appears on 32-bit platform. Attached file when compiled for i686 arch contains __fixunsdfdi function with vmovd %edx,%xmm0 instruction that is clearly not valid on i686 arch. Even when clang is invoked with -mno-avx and -mfpmath=387 options, vmovd is still generated.
I've noticed this because of valgrind crash.
clang -march=i686 -g vg-bug.c && valgrind ./a.out 1.2 => illegal instruction gcc -march=i686 -g vg-bug.c && valgrind ./a.out 1.2 => OK
(closing due to lack of reply)
Clang takes the target arch and the triple from environment, it you don't specify anything else. Did you try -m32?
Isn't -m32 implicit default for 32-bit clang binary?
The command line should be: ' clang -m32 -march=i686 -g vg-bug.c ' , otherwise clang ignores -march=i686
+Elena, see comment #1
Is this a recent regression on trunk or something else?
Elena was adding AVX patterns recently, and there were some predication issues. Elena, does this ring any bells?