[llvm] 97d1b48 - [InstCombine] add tests for xor_of_icmps. nfc

Chenbing Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 13 00:21:25 PDT 2022


Author: Chenbing Zheng
Date: 2022-07-13T15:20:54+08:00
New Revision: 97d1b489802a9abfea8ee40865fcc36e81a80ded

URL: https://github.com/llvm/llvm-project/commit/97d1b489802a9abfea8ee40865fcc36e81a80ded
DIFF: https://github.com/llvm/llvm-project/commit/97d1b489802a9abfea8ee40865fcc36e81a80ded.diff

LOG: [InstCombine] add tests for xor_of_icmps. nfc

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/set.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/set.ll b/llvm/test/Transforms/InstCombine/set.ll
index 55ea762c5bd5..e467f0eab48c 100644
--- a/llvm/test/Transforms/InstCombine/set.ll
+++ b/llvm/test/Transforms/InstCombine/set.ll
@@ -222,8 +222,8 @@ define i1 @xor_of_icmps_commute(i64 %a) {
 
 ; FIXME: This is (a != 5).
 
-define i1 @xor_of_icmps_folds_more(i64 %a) {
-; CHECK-LABEL: @xor_of_icmps_folds_more(
+define i1 @xor_of_icmps_to_ne(i64 %a) {
+; CHECK-LABEL: @xor_of_icmps_to_ne(
 ; CHECK-NEXT:    [[B:%.*]] = icmp sgt i64 [[A:%.*]], 4
 ; CHECK-NEXT:    [[C:%.*]] = icmp slt i64 [[A]], 6
 ; CHECK-NEXT:    [[XOR:%.*]] = xor i1 [[B]], [[C]]
@@ -235,6 +235,43 @@ define i1 @xor_of_icmps_folds_more(i64 %a) {
   ret i1 %xor
 }
 
+define i1 @xor_of_icmps_to_ne_commute(i64 %a) {
+; CHECK-LABEL: @xor_of_icmps_to_ne_commute(
+; CHECK-NEXT:    [[C:%.*]] = icmp sgt i64 [[A:%.*]], 4
+; CHECK-NEXT:    [[B:%.*]] = icmp slt i64 [[A]], 6
+; CHECK-NEXT:    [[XOR:%.*]] = xor i1 [[B]], [[C]]
+; CHECK-NEXT:    ret i1 [[XOR]]
+;
+  %c = icmp sgt i64 %a, 4
+  %b = icmp slt i64 %a, 6
+  %xor = xor i1 %b, %c
+  ret i1 %xor
+}
+
+define i1 @xor_of_icmps_neg_to_ne(i64 %a) {
+; CHECK-LABEL: @xor_of_icmps_neg_to_ne(
+; CHECK-NEXT:    [[B:%.*]] = icmp sgt i64 [[A:%.*]], -6
+; CHECK-NEXT:    [[C:%.*]] = icmp slt i64 [[A]], -4
+; CHECK-NEXT:    [[XOR:%.*]] = xor i1 [[B]], [[C]]
+; CHECK-NEXT:    ret i1 [[XOR]]
+;
+  %b = icmp sgt i64 %a, -6
+  %c = icmp slt i64 %a, -4
+  %xor = xor i1 %b, %c
+  ret i1 %xor
+}
+
+define i1 @xor_of_icmps_to_eq(i8 %a) {
+; CHECK-LABEL: @xor_of_icmps_to_eq(
+; CHECK-NEXT:    [[C:%.*]] = icmp eq i8 [[A:%.*]], 127
+; CHECK-NEXT:    ret i1 [[C]]
+;
+  %c = icmp sgt i8 %a, 126
+  %b = icmp slt i8 %a, 128
+  %xor = xor i1 %b, %c
+  ret i1 %xor
+}
+
 ; https://bugs.llvm.org/show_bug.cgi?id=2844
 
 define i32 @PR2844(i32 %x) {


        


More information about the llvm-commits mailing list