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 | de2b151dbf125af49717807b9cfc1f6f7a5b9ea6 (patch) | |
tree | 0966dab4e700d13996e7fdf0a9556afde6483a8f /lib/CodeGen/RenderMachineFunction.cpp | |
parent | 7b4d31176efe6894bcfaa05257dd5783acda5ddc (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110799 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RenderMachineFunction.cpp')
0 files changed, 0 insertions, 0 deletions