[llvm] 3dd2f02 - [InstCombine] Add (icmp eq B, 0) | (icmp ult A, B) -> (icmp ule A, B-1) vector tests

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 19 03:51:14 PDT 2020


Author: Simon Pilgrim
Date: 2020-10-19T11:48:32+01:00
New Revision: 3dd2f02bb08534bc537f32ad1154773d6710ece9

URL: https://github.com/llvm/llvm-project/commit/3dd2f02bb08534bc537f32ad1154773d6710ece9
DIFF: https://github.com/llvm/llvm-project/commit/3dd2f02bb08534bc537f32ad1154773d6710ece9.diff

LOG: [InstCombine] Add (icmp eq B, 0) | (icmp ult A, B) -> (icmp ule A, B-1) vector tests

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll
index 683518121789..9e1a01b90f0e 100644
--- a/llvm/test/Transforms/InstCombine/icmp.ll
+++ b/llvm/test/Transforms/InstCombine/icmp.ll
@@ -2162,6 +2162,32 @@ define i1 @or_icmp_eq_B_0_icmp_ult_A_B(i64 %a, i64 %b) {
   ret i1 %3
 }
 
+define <2 x i1> @or_icmp_eq_B_0_icmp_ult_A_B_uniform(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: @or_icmp_eq_B_0_icmp_ult_A_B_uniform(
+; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq <2 x i64> [[B:%.*]], zeroinitializer
+; CHECK-NEXT:    [[TMP2:%.*]] = icmp ult <2 x i64> [[A:%.*]], [[B]]
+; CHECK-NEXT:    [[TMP3:%.*]] = or <2 x i1> [[TMP1]], [[TMP2]]
+; CHECK-NEXT:    ret <2 x i1> [[TMP3]]
+;
+  %1 = icmp eq <2 x i64> %b, zeroinitializer
+  %2 = icmp ult <2 x i64> %a, %b
+  %3 = or <2 x i1> %1, %2
+  ret <2 x i1> %3
+}
+
+define <2 x i1> @or_icmp_eq_B_0_icmp_ult_A_B_undef(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: @or_icmp_eq_B_0_icmp_ult_A_B_undef(
+; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq <2 x i64> [[B:%.*]], <i64 0, i64 undef>
+; CHECK-NEXT:    [[TMP2:%.*]] = icmp ult <2 x i64> [[A:%.*]], [[B]]
+; CHECK-NEXT:    [[TMP3:%.*]] = or <2 x i1> [[TMP1]], [[TMP2]]
+; CHECK-NEXT:    ret <2 x i1> [[TMP3]]
+;
+  %1 = icmp eq <2 x i64> %b, <i64 0, i64 undef>
+  %2 = icmp ult <2 x i64> %a, %b
+  %3 = or <2 x i1> %1, %2
+  ret <2 x i1> %3
+}
+
 define i1 @icmp_add_ult_2(i32 %X) {
 ; CHECK-LABEL: @icmp_add_ult_2(
 ; CHECK-NEXT:    [[TMP1:%.*]] = and i32 [[X:%.*]], -2


        


More information about the llvm-commits mailing list