[llvm] 765b5b8 - [ConstProp] add tests for intrinsics with poison ops; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 15 07:47:05 PST 2022


Author: Sanjay Patel
Date: 2022-02-15T10:45:32-05:00
New Revision: 765b5b810589fc0a1f2ed982b6b442648c79f470

URL: https://github.com/llvm/llvm-project/commit/765b5b810589fc0a1f2ed982b6b442648c79f470
DIFF: https://github.com/llvm/llvm-project/commit/765b5b810589fc0a1f2ed982b6b442648c79f470.diff

LOG: [ConstProp] add tests for intrinsics with poison ops; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/ConstProp/min-max.ll
    llvm/test/Transforms/InstSimplify/ConstProp/saturating-add-sub.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/ConstProp/min-max.ll b/llvm/test/Transforms/InstSimplify/ConstProp/min-max.ll
index 4e0f4ccae4c3a..6196333844758 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/min-max.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/min-max.ll
@@ -293,7 +293,7 @@ define <5 x i8> @smax_vec() {
 ; CHECK-LABEL: @smax_vec(
 ; CHECK-NEXT:    ret <5 x i8> <i8 undef, i8 127, i8 127, i8 42, i8 127>
 ;
-  %r = call <5 x i8> @llvm.smax.v5i8(<5 x i8> <i8 undef, i8 undef, i8 1, i8 42, i8 42>, <5 x i8> <i8 undef, i8 1, i8 undef, i8 42, i8 127>)
+  %r = call <5 x i8> @llvm.smax.v5i8(<5 x i8> <i8 poison, i8 undef, i8 1, i8 42, i8 42>, <5 x i8> <i8 undef, i8 1, i8 poison, i8 42, i8 127>)
   ret <5 x i8> %r
 }
 
@@ -309,7 +309,7 @@ define <5 x i8> @smin_vec() {
 ; CHECK-LABEL: @smin_vec(
 ; CHECK-NEXT:    ret <5 x i8> <i8 undef, i8 -128, i8 -128, i8 42, i8 -127>
 ;
-  %r = call <5 x i8> @llvm.smin.v5i8(<5 x i8> <i8 undef, i8 undef, i8 1, i8 42, i8 42>, <5 x i8> <i8 undef, i8 1, i8 undef, i8 42, i8 129>)
+  %r = call <5 x i8> @llvm.smin.v5i8(<5 x i8> <i8 poison, i8 undef, i8 1, i8 42, i8 42>, <5 x i8> <i8 undef, i8 1, i8 poison, i8 42, i8 129>)
   ret <5 x i8> %r
 }
 
@@ -325,7 +325,7 @@ define <5 x i8> @umax_vec() {
 ; CHECK-LABEL: @umax_vec(
 ; CHECK-NEXT:    ret <5 x i8> <i8 undef, i8 -1, i8 -1, i8 42, i8 -128>
 ;
-  %r = call <5 x i8> @llvm.umax.v5i8(<5 x i8> <i8 undef, i8 undef, i8 1, i8 42, i8 42>, <5 x i8> <i8 undef, i8 1, i8 undef, i8 42, i8 128>)
+  %r = call <5 x i8> @llvm.umax.v5i8(<5 x i8> <i8 poison, i8 undef, i8 1, i8 42, i8 42>, <5 x i8> <i8 undef, i8 1, i8 poison, i8 42, i8 128>)
   ret <5 x i8> %r
 }
 
@@ -341,6 +341,6 @@ define <5 x i8> @umin_vec() {
 ; CHECK-LABEL: @umin_vec(
 ; CHECK-NEXT:    ret <5 x i8> <i8 undef, i8 0, i8 0, i8 42, i8 42>
 ;
-  %r = call <5 x i8> @llvm.umin.v5i8(<5 x i8> <i8 undef, i8 undef, i8 1, i8 42, i8 42>, <5 x i8> <i8 undef, i8 1, i8 undef, i8 42, i8 128>)
+  %r = call <5 x i8> @llvm.umin.v5i8(<5 x i8> <i8 poison, i8 undef, i8 1, i8 42, i8 42>, <5 x i8> <i8 undef, i8 1, i8 poison, i8 42, i8 128>)
   ret <5 x i8> %r
 }

diff  --git a/llvm/test/Transforms/InstSimplify/ConstProp/saturating-add-sub.ll b/llvm/test/Transforms/InstSimplify/ConstProp/saturating-add-sub.ll
index 262b00081ebe9..a6e6373a0649a 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/saturating-add-sub.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/saturating-add-sub.ll
@@ -364,3 +364,197 @@ define <2 x i8> @test_ssub_vector_op1_undef_mix2() {
   %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 undef, i8 10>, <2 x i8> <i8 20, i8 undef>)
   ret <2 x i8> %x
 }
+
+; Tests for poison handling
+
+define i8 @test_uadd_scalar_both_poison() {
+; CHECK-LABEL: @test_uadd_scalar_both_poison(
+; CHECK-NEXT:    ret i8 undef
+;
+  %x = call i8 @llvm.uadd.sat.i8(i8 poison, i8 poison)
+  ret i8 %x
+}
+
+define i8 @test_sadd_scalar_both_poison() {
+; CHECK-LABEL: @test_sadd_scalar_both_poison(
+; CHECK-NEXT:    ret i8 undef
+;
+  %x = call i8 @llvm.sadd.sat.i8(i8 poison, i8 poison)
+  ret i8 %x
+}
+
+define i8 @test_usub_scalar_both_poison() {
+; CHECK-LABEL: @test_usub_scalar_both_poison(
+; CHECK-NEXT:    ret i8 undef
+;
+  %x = call i8 @llvm.usub.sat.i8(i8 poison, i8 poison)
+  ret i8 %x
+}
+
+define i8 @test_ssub_scalar_both_poison() {
+; CHECK-LABEL: @test_ssub_scalar_both_poison(
+; CHECK-NEXT:    ret i8 undef
+;
+  %x = call i8 @llvm.ssub.sat.i8(i8 poison, i8 poison)
+  ret i8 %x
+}
+
+define i8 @test_uadd_scalar_op2_poison() {
+; CHECK-LABEL: @test_uadd_scalar_op2_poison(
+; CHECK-NEXT:    ret i8 -1
+;
+  %x = call i8 @llvm.uadd.sat.i8(i8 10, i8 poison)
+  ret i8 %x
+}
+
+define i8 @test_sadd_scalar_op1_poison() {
+; CHECK-LABEL: @test_sadd_scalar_op1_poison(
+; CHECK-NEXT:    ret i8 -1
+;
+  %x = call i8 @llvm.sadd.sat.i8(i8 poison, i8 10)
+  ret i8 %x
+}
+
+define i8 @test_usub_scalar_op2_poison() {
+; CHECK-LABEL: @test_usub_scalar_op2_poison(
+; CHECK-NEXT:    ret i8 0
+;
+  %x = call i8 @llvm.usub.sat.i8(i8 10, i8 poison)
+  ret i8 %x
+}
+
+define i8 @test_usub_scalar_op1_poison() {
+; CHECK-LABEL: @test_usub_scalar_op1_poison(
+; CHECK-NEXT:    ret i8 0
+;
+  %x = call i8 @llvm.usub.sat.i8(i8 poison, i8 10)
+  ret i8 %x
+}
+
+define <2 x i8> @test_uadd_vector_both_poison_splat() {
+; CHECK-LABEL: @test_uadd_vector_both_poison_splat(
+; CHECK-NEXT:    ret <2 x i8> undef
+;
+  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> poison, <2 x i8> poison)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_sadd_vector_both_poison_splat() {
+; CHECK-LABEL: @test_sadd_vector_both_poison_splat(
+; CHECK-NEXT:    ret <2 x i8> undef
+;
+  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> poison, <2 x i8> poison)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_usub_vector_both_poison_splat() {
+; CHECK-LABEL: @test_usub_vector_both_poison_splat(
+; CHECK-NEXT:    ret <2 x i8> undef
+;
+  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> poison, <2 x i8> poison)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_ssub_vector_both_poison_splat() {
+; CHECK-LABEL: @test_ssub_vector_both_poison_splat(
+; CHECK-NEXT:    ret <2 x i8> undef
+;
+  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> poison, <2 x i8> poison)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_uadd_vector_op2_poison_splat() {
+; CHECK-LABEL: @test_uadd_vector_op2_poison_splat(
+; CHECK-NEXT:    ret <2 x i8> <i8 -1, i8 -1>
+;
+  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 10, i8 20>, <2 x i8> poison)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_sadd_vector_op1_poison_splat() {
+; CHECK-LABEL: @test_sadd_vector_op1_poison_splat(
+; CHECK-NEXT:    ret <2 x i8> <i8 -1, i8 -1>
+;
+  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> poison, <2 x i8> <i8 10, i8 20>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_usub_vector_op2_poison_splat() {
+; CHECK-LABEL: @test_usub_vector_op2_poison_splat(
+; CHECK-NEXT:    ret <2 x i8> zeroinitializer
+;
+  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 10, i8 20>, <2 x i8> poison)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_ssub_vector_op1_poison_splat() {
+; CHECK-LABEL: @test_ssub_vector_op1_poison_splat(
+; CHECK-NEXT:    ret <2 x i8> zeroinitializer
+;
+  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> poison, <2 x i8> <i8 10, i8 20>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_uadd_vector_op2_poison_mix1() {
+; CHECK-LABEL: @test_uadd_vector_op2_poison_mix1(
+; CHECK-NEXT:    ret <2 x i8> <i8 30, i8 undef>
+;
+  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 10, i8 poison>, <2 x i8> <i8 20, i8 poison>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_uadd_vector_op2_poison_mix2() {
+; CHECK-LABEL: @test_uadd_vector_op2_poison_mix2(
+; CHECK-NEXT:    ret <2 x i8> <i8 -1, i8 -1>
+;
+  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 10, i8 poison>, <2 x i8> <i8 poison, i8 20>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_sadd_vector_op1_poison_mix1() {
+; CHECK-LABEL: @test_sadd_vector_op1_poison_mix1(
+; CHECK-NEXT:    ret <2 x i8> <i8 undef, i8 30>
+;
+  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 poison, i8 10>, <2 x i8> <i8 poison, i8 20>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_sadd_vector_op1_poison_mix2() {
+; CHECK-LABEL: @test_sadd_vector_op1_poison_mix2(
+; CHECK-NEXT:    ret <2 x i8> <i8 -1, i8 -1>
+;
+  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 poison, i8 10>, <2 x i8> <i8 20, i8 poison>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_usub_vector_op2_poison_mix1() {
+; CHECK-LABEL: @test_usub_vector_op2_poison_mix1(
+; CHECK-NEXT:    ret <2 x i8> <i8 0, i8 undef>
+;
+  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 10, i8 poison>, <2 x i8> <i8 20, i8 poison>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_usub_vector_op2_poison_mix2() {
+; CHECK-LABEL: @test_usub_vector_op2_poison_mix2(
+; CHECK-NEXT:    ret <2 x i8> zeroinitializer
+;
+  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 10, i8 poison>, <2 x i8> <i8 poison, i8 20>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_ssub_vector_op1_poison_mix1() {
+; CHECK-LABEL: @test_ssub_vector_op1_poison_mix1(
+; CHECK-NEXT:    ret <2 x i8> <i8 undef, i8 -10>
+;
+  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 poison, i8 10>, <2 x i8> <i8 poison, i8 20>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_ssub_vector_op1_poison_mix2() {
+; CHECK-LABEL: @test_ssub_vector_op1_poison_mix2(
+; CHECK-NEXT:    ret <2 x i8> zeroinitializer
+;
+  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 poison, i8 10>, <2 x i8> <i8 20, i8 poison>)
+  ret <2 x i8> %x
+}


        


More information about the llvm-commits mailing list