[LLVMdev] ARM thumb-2 instruction used for non-thumb2 CPUs
Damjan Marion
damjan.marion at gmail.com
Wed Jun 22 03:49:00 PDT 2011
Hi,
I just realized that clang produces Thumb-2 instruction in code even when older CPU type which doesn't suport Thumb-2 is specified.
Here is output:
# /opt/llvm/bin/clang -S -ccc-host-triple arm-unknown-freebsd -mcpu=arm926ej-s -mfloat-abi=soft -v -o rrx.S rrx.c
clang version 3.0 (http://llvm.org/git/clang.git 98138cdfdee05c0afbab2b209ce8cfe4a52474e1)
Target: arm-unknown-freebsd
Thread model: posix
"/opt/llvm/bin/clang" -cc1 -triple armv5e-unknown-freebsd -S -disable-free -main-file-name rrx.c -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-abi apcs-gnu -target-cpu arm926ej-s -msoft-float -mfloat-abi soft -target-feature +soft-float -target-feature +soft-float-abi -target-feature -neon -target-linker-version 123.2 -momit-leaf-frame-pointer -v -coverage-file rrx.S -resource-dir /opt/llvm/bin/../lib/clang/3.0 -ferror-limit 19 -fmessage-length 162 -fno-signed-char -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o rrx.S -x c rrx.c
clang -cc1 version 3.0 based upon llvm 3.0svn hosted on x86_64-apple-darwin10.7.0
#include "..." search starts here:
#include <...> search starts here:
/opt/llvm/bin/../lib/clang/3.0/include
/usr/include
End of search list.
Code:
void bla (long long a)
{
if (a & ((unsigned long long)1 << 24))
a >>= 1;
}
generated .S:
bla:
str r11, [sp, #-4]!
mov r11, sp
sub sp, sp, #20
bic sp, sp, #7
str r1, [sp, #12]
str r0, [sp, #8]
ldrb r2, [sp, #11]
tst r2, #1
str r0, [sp, #4]
str r1, [sp]
beq .LBB0_2
b .LBB0_1
.LBB0_1:
ldr r0, [sp, #8]
ldr r1, [sp, #12]
asrs r1, r1, #1
rrx r0, r0 << Thumb-2 instruction
str r1, [sp, #12]
str r0, [sp, #8]
.LBB0_2:
mov sp, r11
ldr r11, [sp], #4
bx lr
rrx r0,r0 is thumb-2 instruction, however target-cpu is set to arm926ej-s which is ARMv5E architecture and it doesn't support Thumb-2.
Is this a known issue?
Thanks,
Damjan
More information about the llvm-dev
mailing list