summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/test/Transforms/InstCombine/reuse-constant-from-select-in-icmp.ll16
1 files changed, 13 insertions, 3 deletions
diff --git a/llvm/test/Transforms/InstCombine/reuse-constant-from-select-in-icmp.ll b/llvm/test/Transforms/InstCombine/reuse-constant-from-select-in-icmp.ll
index 7128922df74..5964c02228c 100644
--- a/llvm/test/Transforms/InstCombine/reuse-constant-from-select-in-icmp.ll
+++ b/llvm/test/Transforms/InstCombine/reuse-constant-from-select-in-icmp.ll
@@ -263,9 +263,9 @@ define i32 @n21_equality(i32 %x, i32 %y) {
ret i32 %r
}
-; We don't touch sign checks
-define i32 @n22_sign_check(i32 %x, i32 %y) {
-; CHECK-LABEL: @n22_sign_check(
+; There is nothing special about sign-bit-tests, we can fold them.
+define i32 @t22_sign_check(i32 %x, i32 %y) {
+; CHECK-LABEL: @t22_sign_check(
; CHECK-NEXT: [[T:%.*]] = icmp slt i32 [[X:%.*]], 0
; CHECK-NEXT: [[R:%.*]] = select i1 [[T]], i32 -1, i32 [[Y:%.*]]
; CHECK-NEXT: ret i32 [[R]]
@@ -274,6 +274,16 @@ define i32 @n22_sign_check(i32 %x, i32 %y) {
%r = select i1 %t, i32 -1, i32 %y
ret i32 %r
}
+define i32 @t22_sign_check2(i32 %x, i32 %y) {
+; CHECK-LABEL: @t22_sign_check2(
+; CHECK-NEXT: [[T:%.*]] = icmp sgt i32 [[X:%.*]], -1
+; CHECK-NEXT: [[R:%.*]] = select i1 [[T]], i32 0, i32 [[Y:%.*]]
+; CHECK-NEXT: ret i32 [[R]]
+;
+ %t = icmp sgt i32 %x, -1
+ %r = select i1 %t, i32 0, i32 %y
+ ret i32 %r
+}
; If the types don't match we currently don't do anything.
define i32 @n23_type_mismatch(i64 %x, i32 %y) {
OpenPOWER on IntegriCloud