llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

clang produces AVX instructions when generating code for arch that doesn't support them

Open llvmbot opened this issue 11 years ago • 6 comments

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

llvmbot avatar Feb 25 '15 15:02 llvmbot

(closing due to lack of reply)

nico avatar Sep 02 '21 00:09 nico

Clang takes the target arch and the triple from environment, it you don't specify anything else. Did you try -m32?

delena avatar Jul 24 '17 06:07 delena

Isn't -m32 implicit default for 32-bit clang binary?

llvmbot avatar Jul 23 '17 23:07 llvmbot

The command line should be: ' clang -m32 -march=i686 -g vg-bug.c ' , otherwise clang ignores -march=i686

delena avatar Jul 23 '17 12:07 delena

+Elena, see comment #​1

rnk avatar Feb 25 '15 19:02 rnk

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?

rnk avatar Feb 25 '15 19:02 rnk