summaryrefslogtreecommitdiff
path: root/test/CodeGen/ARM/select-imm.ll
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2011-07-13 00:42:17 +0000
committerEvan Cheng <evan.cheng@apple.com>2011-07-13 00:42:17 +0000
commite721f5c8d3ea2cc2cc8c3c308ce8bdd8a3fc3b32 (patch)
tree9d3a3b566011131e0112dd247270ca0dfc4f92d8 /test/CodeGen/ARM/select-imm.ll
parent3641e811729fc7f21039af595d62bc8e696ff407 (diff)
downloadllvm-e721f5c8d3ea2cc2cc8c3c308ce8bdd8a3fc3b32.tar.gz
llvm-e721f5c8d3ea2cc2cc8c3c308ce8bdd8a3fc3b32.tar.bz2
llvm-e721f5c8d3ea2cc2cc8c3c308ce8bdd8a3fc3b32.tar.xz
Improve codegen for select's:
if (x != 0) x = 1 if (x == 1) x = 1 Previous codegen looks like this: mov r1, r0 cmp r1, #1 mov r0, #0 moveq r0, #1 The naive lowering select between two different values. It should recognize the test is equality test so it's more a conditional move rather than a select: cmp r0, #1 movne r0, #0 rdar://9758317 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135017 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/ARM/select-imm.ll')
-rw-r--r--test/CodeGen/ARM/select-imm.ll36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/CodeGen/ARM/select-imm.ll b/test/CodeGen/ARM/select-imm.ll
index 158c015f46..f43dde52bb 100644
--- a/test/CodeGen/ARM/select-imm.ll
+++ b/test/CodeGen/ARM/select-imm.ll
@@ -76,3 +76,39 @@ entry:
%1 = select i1 %0, i32 4283826005, i32 %x
ret i32 %1
}
+
+; rdar://9758317
+define i32 @t5(i32 %a) nounwind {
+entry:
+; ARM: t5:
+; ARM-NOT: mov
+; ARM: cmp r0, #1
+; ARM-NOT: mov
+; ARM: movne r0, #0
+
+; THUMB2: t5:
+; THUMB2-NOT: mov
+; THUMB2: cmp r0, #1
+; THUMB2: it ne
+; THUMB2: movne r0, #0
+ %cmp = icmp eq i32 %a, 1
+ %conv = zext i1 %cmp to i32
+ ret i32 %conv
+}
+
+define i32 @t6(i32 %a) nounwind {
+entry:
+; ARM: t6:
+; ARM-NOT: mov
+; ARM: cmp r0, #0
+; ARM: movne r0, #1
+
+; THUMB2: t6:
+; THUMB2-NOT: mov
+; THUMB2: cmp r0, #0
+; THUMB2: it ne
+; THUMB2: movne r0, #1
+ %tobool = icmp ne i32 %a, 0
+ %lnot.ext = zext i1 %tobool to i32
+ ret i32 %lnot.ext
+}