[llvm] 36bd25d - [InstCombine][test] add tests for icmp with constant and offset; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 30 10:45:22 PDT 2021


Author: Sanjay Patel
Date: 2021-06-30T13:37:31-04:00
New Revision: 36bd25db3dd5b76f3ab31fc95bd04f18a8af6347

URL: https://github.com/llvm/llvm-project/commit/36bd25db3dd5b76f3ab31fc95bd04f18a8af6347
DIFF: https://github.com/llvm/llvm-project/commit/36bd25db3dd5b76f3ab31fc95bd04f18a8af6347.diff

LOG: [InstCombine][test] add tests for icmp with constant and offset; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/icmp-add.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/icmp-add.ll b/llvm/test/Transforms/InstCombine/icmp-add.ll
index a35d546f23ae..e6cd8e74d7a9 100644
--- a/llvm/test/Transforms/InstCombine/icmp-add.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-add.ll
@@ -747,3 +747,49 @@ define i1 @with_nuw_large_negative(i8 %x, i8 %y) {
   %tobool = icmp eq i8 %t2, %t1
   ret i1 %tobool
 }
+
+define i1 @ugt_offset(i8 %a) {
+; CHECK-LABEL: @ugt_offset(
+; CHECK-NEXT:    [[T:%.*]] = add i8 [[A:%.*]], 124
+; CHECK-NEXT:    [[OV:%.*]] = icmp ugt i8 [[T]], -5
+; CHECK-NEXT:    ret i1 [[OV]]
+;
+  %t = add i8 %a, 124
+  %ov = icmp ugt i8 %t, 251
+  ret i1 %ov
+}
+
+define i1 @ugt_offset_use(i32 %a) {
+; CHECK-LABEL: @ugt_offset_use(
+; CHECK-NEXT:    [[T:%.*]] = add i32 [[A:%.*]], 42
+; CHECK-NEXT:    call void @use(i32 [[T]])
+; CHECK-NEXT:    [[OV:%.*]] = icmp ugt i32 [[T]], -2147483607
+; CHECK-NEXT:    ret i1 [[OV]]
+;
+  %t = add i32 %a, 42
+  call void @use(i32 %t)
+  %ov = icmp ugt i32 %t, 2147483689
+  ret i1 %ov
+}
+
+define <2 x i1> @ugt_offset_splat(<2 x i5> %a) {
+; CHECK-LABEL: @ugt_offset_splat(
+; CHECK-NEXT:    [[T:%.*]] = add <2 x i5> [[A:%.*]], <i5 9, i5 9>
+; CHECK-NEXT:    [[OV:%.*]] = icmp ugt <2 x i5> [[T]], <i5 -8, i5 -8>
+; CHECK-NEXT:    ret <2 x i1> [[OV]]
+;
+  %t = add <2 x i5> %a, <i5 9, i5 9>
+  %ov = icmp ugt <2 x i5> %t, <i5 24, i5 24>
+  ret <2 x i1> %ov
+}
+
+define i1 @ugt_wrong_offset(i8 %a) {
+; CHECK-LABEL: @ugt_wrong_offset(
+; CHECK-NEXT:    [[T:%.*]] = add i8 [[A:%.*]], 123
+; CHECK-NEXT:    [[OV:%.*]] = icmp ugt i8 [[T]], -5
+; CHECK-NEXT:    ret i1 [[OV]]
+;
+  %t = add i8 %a, 123
+  %ov = icmp ugt i8 %t, 251
+  ret i1 %ov
+}


        


More information about the llvm-commits mailing list