[ARM] Materialise some boolean values to avoid a branch
This patch combines some cases of ARMISD::CMOV for integers that arise in comparisons of the form
a != b ? x : 0
a == b ? 0 : x
and that currently (e.g. in Thumb1) are emitted as branches.
Differential Revision: https://reviews.llvm.org/D34515
llvm-svn: 325323
diff --git a/llvm/test/CodeGen/Thumb/constants.ll b/llvm/test/CodeGen/Thumb/constants.ll
index b1145d7..7f88500 100644
--- a/llvm/test/CodeGen/Thumb/constants.ll
+++ b/llvm/test/CodeGen/Thumb/constants.ll
@@ -17,3 +17,20 @@
define i32 @mov_and_add2() {
ret i32 511
}
+
+; CHECK-T1-LABEL: @test64
+; CHECK-T2-LABEL: @test64
+; CHECK-T1: movs r4, #0
+; CHECK-T1: mvns r5, r4
+; CHECK-T1: mov r0, r5
+; CHECK-T1: subs r0, #15
+; CHECK-T2: subs.w r0, r{{[0-9]+}}, #15
+; CHECK-T2-NEXT: sbc r1, r{{[0-9]+}}, #0
+define i32 @test64() {
+entry:
+ tail call void @fn1(i64 -1)
+ tail call void @fn1(i64 -1)
+ tail call void @fn1(i64 -16)
+ ret i32 0
+}
+declare void @fn1(i64) ;