[llvm] 5171587 - [InstCombine] Add undef/non-splat tests for add/sub + icmp eq; NFC

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 29 12:00:02 PST 2020


Author: Nikita Popov
Date: 2020-01-29T20:56:58+01:00
New Revision: 5171587a5f50aecb43e6241c3dbc36f2cf615749

URL: https://github.com/llvm/llvm-project/commit/5171587a5f50aecb43e6241c3dbc36f2cf615749
DIFF: https://github.com/llvm/llvm-project/commit/5171587a5f50aecb43e6241c3dbc36f2cf615749.diff

LOG: [InstCombine] Add undef/non-splat tests for add/sub + icmp eq; NFC

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/icmp-add.ll b/llvm/test/Transforms/InstCombine/icmp-add.ll
index 5cf0cfb8d33d..ce478b9fc386 100644
--- a/llvm/test/Transforms/InstCombine/icmp-add.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-add.ll
@@ -621,3 +621,47 @@ define void @bzip2(i8 %a, i8 %b, i8 %x) {
   call void @use8(i8 %add1)
   ret void
 }
+
+define <2 x i1> @icmp_eq_add_undef(<2 x i32> %a) {
+; CHECK-LABEL: @icmp_eq_add_undef(
+; CHECK-NEXT:    [[ADD:%.*]] = add <2 x i32> [[A:%.*]], <i32 5, i32 undef>
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i32> [[ADD]], <i32 10, i32 10>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %add = add <2 x i32> %a, <i32 5, i32 undef>
+  %cmp = icmp eq <2 x i32> %add, <i32 10, i32 10>
+  ret <2 x i1> %cmp
+}
+
+define <2 x i1> @icmp_eq_add_non_splat(<2 x i32> %a) {
+; CHECK-LABEL: @icmp_eq_add_non_splat(
+; CHECK-NEXT:    [[ADD:%.*]] = add <2 x i32> [[A:%.*]], <i32 5, i32 6>
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i32> [[ADD]], <i32 10, i32 10>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %add = add <2 x i32> %a, <i32 5, i32 6>
+  %cmp = icmp eq <2 x i32> %add, <i32 10, i32 10>
+  ret <2 x i1> %cmp
+}
+
+define <2 x i1> @icmp_eq_add_undef2(<2 x i32> %a) {
+; CHECK-LABEL: @icmp_eq_add_undef2(
+; CHECK-NEXT:    [[ADD:%.*]] = add <2 x i32> [[A:%.*]], <i32 5, i32 5>
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i32> [[ADD]], <i32 10, i32 undef>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %add = add <2 x i32> %a, <i32 5, i32 5>
+  %cmp = icmp eq <2 x i32> %add, <i32 10, i32 undef>
+  ret <2 x i1> %cmp
+}
+
+define <2 x i1> @icmp_eq_add_non_splat2(<2 x i32> %a) {
+; CHECK-LABEL: @icmp_eq_add_non_splat2(
+; CHECK-NEXT:    [[ADD:%.*]] = add <2 x i32> [[A:%.*]], <i32 5, i32 5>
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i32> [[ADD]], <i32 10, i32 11>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %add = add <2 x i32> %a, <i32 5, i32 5>
+  %cmp = icmp eq <2 x i32> %add, <i32 10, i32 11>
+  ret <2 x i1> %cmp
+}

diff  --git a/llvm/test/Transforms/InstCombine/icmp-sub.ll b/llvm/test/Transforms/InstCombine/icmp-sub.ll
index 0486263ff53e..4b3f7084a437 100644
--- a/llvm/test/Transforms/InstCombine/icmp-sub.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-sub.ll
@@ -143,3 +143,47 @@ define <2 x i1> @test_sub_255_Y_eq_255_vec(<2 x i8> %y) {
   %z = icmp eq <2 x i8> %s, <i8 255, i8 255>
   ret <2 x i1> %z
 }
+
+define <2 x i1> @icmp_eq_sub_undef(<2 x i32> %a) {
+; CHECK-LABEL: @icmp_eq_sub_undef(
+; CHECK-NEXT:    [[SUB:%.*]] = sub <2 x i32> <i32 15, i32 undef>, [[A:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i32> [[SUB]], <i32 10, i32 10>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %sub = sub <2 x i32> <i32 15, i32 undef>, %a
+  %cmp = icmp eq <2 x i32> %sub, <i32 10, i32 10>
+  ret <2 x i1> %cmp
+}
+
+define <2 x i1> @icmp_eq_sub_non_splat(<2 x i32> %a) {
+; CHECK-LABEL: @icmp_eq_sub_non_splat(
+; CHECK-NEXT:    [[SUB:%.*]] = sub <2 x i32> <i32 15, i32 16>, [[A:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i32> [[SUB]], <i32 10, i32 10>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %sub = sub <2 x i32> <i32 15, i32 16>, %a
+  %cmp = icmp eq <2 x i32> %sub, <i32 10, i32 10>
+  ret <2 x i1> %cmp
+}
+
+define <2 x i1> @icmp_eq_sub_undef2(<2 x i32> %a) {
+; CHECK-LABEL: @icmp_eq_sub_undef2(
+; CHECK-NEXT:    [[SUB:%.*]] = sub <2 x i32> <i32 15, i32 15>, [[A:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i32> [[SUB]], <i32 10, i32 undef>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %sub = sub <2 x i32> <i32 15, i32 15>, %a
+  %cmp = icmp eq <2 x i32> %sub, <i32 10, i32 undef>
+  ret <2 x i1> %cmp
+}
+
+define <2 x i1> @icmp_eq_sub_non_splat2(<2 x i32> %a) {
+; CHECK-LABEL: @icmp_eq_sub_non_splat2(
+; CHECK-NEXT:    [[SUB:%.*]] = sub <2 x i32> <i32 15, i32 15>, [[A:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i32> [[SUB]], <i32 10, i32 11>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %sub = sub <2 x i32> <i32 15, i32 15>, %a
+  %cmp = icmp eq <2 x i32> %sub, <i32 10, i32 11>
+  ret <2 x i1> %cmp
+}


        


More information about the llvm-commits mailing list