Bill Wendling
de2b151dbf
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
2010-08-11 08:43:16 +00:00
..
2010-05-02 15:36:26 +00:00
2010-05-02 15:36:26 +00:00
2010-05-02 15:36:26 +00:00
2010-06-15 21:58:33 +00:00
2010-06-15 21:58:33 +00:00
2010-05-07 17:03:48 +00:00
2010-06-15 21:58:33 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-15 20:42:00 +00:00
2010-06-15 20:42:00 +00:00
2010-06-15 20:42:00 +00:00
2010-06-15 20:42:00 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-07-01 21:55:59 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-15 19:04:29 +00:00
2010-06-15 19:04:29 +00:00
2010-03-17 17:52:21 +00:00
2010-06-15 05:56:31 +00:00
2010-05-21 21:05:32 +00:00
2010-06-17 15:18:27 +00:00
2010-03-20 22:20:40 +00:00
2010-04-07 20:43:35 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-05-15 02:18:07 +00:00
2010-05-18 00:03:40 +00:00
2010-05-17 17:18:59 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-05-20 18:39:53 +00:00
2010-05-27 23:57:25 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-06-21 21:21:14 +00:00
2010-06-21 18:46:08 +00:00
2010-06-25 23:14:54 +00:00
2010-06-28 23:40:25 +00:00
2010-07-09 01:32:11 +00:00
2010-06-29 18:42:49 +00:00
2010-07-26 18:45:39 +00:00
2010-08-04 21:56:30 +00:00
2010-07-09 20:27:06 +00:00
2010-04-17 21:29:25 +00:00
2010-04-17 21:29:25 +00:00
2010-08-06 15:35:32 +00:00
2010-06-15 19:04:29 +00:00
2010-03-17 17:52:21 +00:00
2010-06-22 22:04:24 +00:00
2010-06-15 19:04:29 +00:00
2010-07-17 03:30:54 +00:00
2010-04-22 23:24:18 +00:00
2010-07-08 01:18:23 +00:00
2010-06-04 01:01:04 +00:00
2010-06-18 20:59:25 +00:00
2010-08-11 07:17:46 +00:00
2010-05-21 00:43:17 +00:00
2010-05-21 00:43:17 +00:00
2010-07-21 22:26:11 +00:00
2010-05-21 00:43:17 +00:00
2010-06-24 22:00:37 +00:00
2010-05-21 00:43:17 +00:00
2010-05-21 00:43:17 +00:00
2010-05-21 00:43:17 +00:00
2010-03-25 23:47:34 +00:00
2010-03-25 23:47:34 +00:00
2010-05-21 00:43:17 +00:00
2010-03-14 18:42:52 +00:00
2010-03-25 23:47:34 +00:00
2010-07-15 22:07:12 +00:00
2010-06-17 15:18:27 +00:00
2010-03-25 23:47:34 +00:00
2010-04-17 16:29:15 +00:00
2010-04-17 16:29:15 +00:00
2010-06-18 23:09:54 +00:00
2010-05-03 14:35:47 +00:00
2010-06-23 18:56:06 +00:00
2010-03-16 16:19:07 +00:00
2010-03-16 16:19:07 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-05-27 22:08:38 +00:00
2010-06-04 01:01:24 +00:00
2010-06-04 01:01:24 +00:00
2010-03-17 17:52:21 +00:00
2010-08-11 01:05:02 +00:00
2010-06-25 22:42:03 +00:00
2010-08-10 22:16:05 +00:00
2010-06-04 23:28:13 +00:00
2010-05-15 18:16:59 +00:00
2010-07-13 21:16:48 +00:00
2010-06-17 15:18:27 +00:00
2010-04-15 05:28:43 +00:00
2010-06-17 15:18:27 +00:00
2010-08-11 08:43:16 +00:00
2010-06-17 15:18:27 +00:00
2010-03-17 17:52:21 +00:00
2010-07-14 17:45:16 +00:00
2010-03-17 17:52:21 +00:00
2010-06-17 15:18:27 +00:00
2010-06-17 15:18:27 +00:00
2010-07-11 04:01:49 +00:00
2010-08-04 00:12:08 +00:00
2010-05-03 22:36:46 +00:00
2010-05-19 01:08:17 +00:00
2010-07-14 01:22:12 +00:00
2010-06-17 15:18:27 +00:00
2010-07-06 16:24:34 +00:00
2010-04-20 00:17:16 +00:00
2010-05-03 22:36:46 +00:00
2010-05-03 22:36:46 +00:00
2010-05-03 22:36:46 +00:00
2010-05-03 22:36:46 +00:00
2010-05-03 22:36:46 +00:00
2010-05-03 22:36:46 +00:00
2010-07-14 06:31:50 +00:00
2010-05-03 22:36:46 +00:00
2010-05-03 22:36:46 +00:00
2010-06-17 15:18:27 +00:00
2010-04-20 00:17:16 +00:00
2010-04-20 00:17:16 +00:00
2010-04-20 00:17:16 +00:00
2010-04-20 00:17:16 +00:00
2010-04-20 00:17:16 +00:00
2010-05-03 22:36:46 +00:00
2010-05-03 22:36:46 +00:00
2010-05-03 22:36:46 +00:00
2010-05-03 22:36:46 +00:00