[llvm] 89b0044 - [InstSimplify] Add test for implied cond with equal ops and constant (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 1 03:23:45 PST 2023


Author: Nikita Popov
Date: 2023-12-01T12:18:27+01:00
New Revision: 89b0044ca9a6fb233f8d6dd16db6bd4acc3d3f61

URL: https://github.com/llvm/llvm-project/commit/89b0044ca9a6fb233f8d6dd16db6bd4acc3d3f61
DIFF: https://github.com/llvm/llvm-project/commit/89b0044ca9a6fb233f8d6dd16db6bd4acc3d3f61.diff

LOG: [InstSimplify] Add test for implied cond with equal ops and constant (NFC)

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/implies.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/implies.ll b/llvm/test/Transforms/InstSimplify/implies.ll
index 41f1995428473a1..75044f4d9a356fa 100644
--- a/llvm/test/Transforms/InstSimplify/implies.ll
+++ b/llvm/test/Transforms/InstSimplify/implies.ll
@@ -499,4 +499,30 @@ define i1 @lshr_value(i32 %length.i, i32 %i, i32 %v) {
   ret i1 %res
 }
 
+define i1 @same_ops_with_constant(i8 %x) {
+; CHECK-LABEL: @same_ops_with_constant(
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp sgt i8 [[X:%.*]], 5
+; CHECK-NEXT:    [[CMP2:%.*]] = icmp ugt i8 [[X]], 5
+; CHECK-NEXT:    [[RES:%.*]] = icmp ule i1 [[CMP1]], [[CMP2]]
+; CHECK-NEXT:    ret i1 [[RES]]
+;
+  %cmp1 = icmp sgt i8 %x, 5
+  %cmp2 = icmp ugt i8 %x, 5
+  %res = icmp ule i1 %cmp1, %cmp2
+  ret i1 %res
+}
+
+define i1 @same_ops_with_constant_wrong_sign(i8 %x) {
+; CHECK-LABEL: @same_ops_with_constant_wrong_sign(
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp sgt i8 [[X:%.*]], -5
+; CHECK-NEXT:    [[CMP2:%.*]] = icmp ugt i8 [[X]], -5
+; CHECK-NEXT:    [[RES:%.*]] = icmp ule i1 [[CMP1]], [[CMP2]]
+; CHECK-NEXT:    ret i1 [[RES]]
+;
+  %cmp1 = icmp sgt i8 %x, -5
+  %cmp2 = icmp ugt i8 %x, -5
+  %res = icmp ule i1 %cmp1, %cmp2
+  ret i1 %res
+}
+
 declare void @llvm.assume(i1)


        


More information about the llvm-commits mailing list