diff options
author | Bill Wendling <isanbard@gmail.com> | 2010-08-11 08:43:16 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2010-08-11 08:43:16 +0000 |
commit | 6a98131468162950c22a866d736e66e300fb2803 (patch) | |
tree | 1238cad29c373526d62a731008774647017410f7 /clang/lib/Frontend/PCHWriter.cpp | |
parent | 5190f092911b2857fd0521f5ac993cb723262483 (diff) | |
download | bcm5719-llvm-6a98131468162950c22a866d736e66e300fb2803.tar.gz bcm5719-llvm-6a98131468162950c22a866d736e66e300fb2803.zip |
Consider this code snippet:
float t1(int argc) {
return (argc == 1123) ? 1.234f : 2.38213f;
}
We would generate truly awful code on ARM (those with a weak stomach should look
away):
_t1:
movw r1, #1123
movs r2, #1
movs r3, #0
cmp r0, r1
mov.w r0, #0
it eq
moveq r0, r2
movs r1, #4
cmp r0, #0
it ne
movne r3, r1
adr r0, #LCPI1_0
ldr r0, [r0, r3]
bx lr
The problem was that legalization was creating a cascade of SELECT_CC nodes, for
for the comparison of "argc == 1123" which was fed into a SELECT node for the ?:
statement which was itself converted to a SELECT_CC node. This is because the
ARM back-end doesn't have custom lowering for SELECT nodes, so it used the
default "Expand".
I added a fairly simple "LowerSELECT" to the ARM back-end. It takes care of this
testcase, but can obviously be expanded to include more cases.
Now we generate this, which looks optimal to me:
_t1:
movw r1, #1123
movs r2, #0
cmp r0, r1
adr r0, #LCPI0_0
it eq
moveq r2, #4
ldr r0, [r0, r2]
bx lr
.align 2
LCPI0_0:
.long 1075344593 @ float 2.382130e+00
.long 1067316150 @ float 1.234000e+00
llvm-svn: 110799
Diffstat (limited to 'clang/lib/Frontend/PCHWriter.cpp')
0 files changed, 0 insertions, 0 deletions