[InstSimplify] Fold division by zero to poison
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 3 Jan 2021 17:19:37 +0000 (18:19 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Sun, 3 Jan 2021 19:52:45 +0000 (20:52 +0100)
Div/rem by zero is immediate undefined behavior and anything goes.
Currently we fold it to undef, this patch changes it to fold to
poison instead, which is slightly stronger.

Differential Revision: https://reviews.llvm.org/D93995

16 files changed:
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstCombine/add-shl-sdiv-to-srem.ll
llvm/test/Transforms/InstCombine/div.ll
llvm/test/Transforms/InstCombine/icmp-div-constant.ll
llvm/test/Transforms/InstCombine/inselt-binop-inseltpoison.ll
llvm/test/Transforms/InstCombine/inselt-binop.ll
llvm/test/Transforms/InstCombine/rem.ll
llvm/test/Transforms/InstCombine/sdiv-exact-by-negative-power-of-two.ll
llvm/test/Transforms/InstCombine/sdiv-exact-by-power-of-two.ll
llvm/test/Transforms/InstCombine/shift.ll
llvm/test/Transforms/InstCombine/vector-udiv.ll
llvm/test/Transforms/InstCombine/vector-urem.ll
llvm/test/Transforms/InstSimplify/div.ll
llvm/test/Transforms/InstSimplify/rem.ll
llvm/test/Transforms/InstSimplify/undef.ll
llvm/test/Transforms/SLPVectorizer/X86/alternate-int-inseltpoison.ll

index 4706969eafc073bb4ab5edefd531c3b80b1b05a3..0655374cbc1dd3faa4215aad5fcb379bf875af28 100644 (file)
@@ -924,19 +924,19 @@ static Value *simplifyDivRem(Value *Op0, Value *Op1, bool IsDiv,
                              const SimplifyQuery &Q) {
   Type *Ty = Op0->getType();
 
-  // X / undef -> undef
-  // X % undef -> undef
+  // X / undef -> poison
+  // X % undef -> poison
   if (Q.isUndefValue(Op1))
-    return Op1;
+    return PoisonValue::get(Ty);
 
-  // X / 0 -> undef
-  // X % 0 -> undef
+  // X / 0 -> poison
+  // X % 0 -> poison
   // We don't need to preserve faults!
   if (match(Op1, m_Zero()))
-    return UndefValue::get(Ty);
+    return PoisonValue::get(Ty);
 
-  // If any element of a constant divisor fixed width vector is zero or undef,
-  // the whole op is undef.
+  // If any element of a constant divisor fixed width vector is zero or undef
+  // the behavior is undefined and we can fold the whole op to poison.
   auto *Op1C = dyn_cast<Constant>(Op1);
   auto *VTy = dyn_cast<FixedVectorType>(Ty);
   if (Op1C && VTy) {
@@ -944,7 +944,7 @@ static Value *simplifyDivRem(Value *Op0, Value *Op1, bool IsDiv,
     for (unsigned i = 0; i != NumElts; ++i) {
       Constant *Elt = Op1C->getAggregateElement(i);
       if (Elt && (Elt->isNullValue() || Q.isUndefValue(Elt)))
-        return UndefValue::get(Ty);
+        return PoisonValue::get(Ty);
     }
   }
 
index 57a10c165f15b325e9c7a2e84a57fe644f4c4d54..1dee5eb90ea1e11cddd8ac5d5671b01e71c902da 100644 (file)
@@ -212,7 +212,7 @@ define <2 x i64> @add-shl-sdiv-negative4(<2 x i64> %x) {
 
 define <3 x i8> @add-shl-sdiv-3xi8-undef0(<3 x i8> %x) {
 ; CHECK-LABEL: @add-shl-sdiv-3xi8-undef0(
-; CHECK-NEXT:    ret <3 x i8> [[X:%.*]]
+; CHECK-NEXT:    ret <3 x i8> poison
 ;
   %sd = sdiv <3 x i8> %x, <i8 -4, i8 undef, i8 -4>
   %sl = shl <3 x i8> %sd, <i8 2, i8 2, i8 2>
index e06faf43348b0575341bbe6fb7ae6bea70f19084..835db5e2c6ca603c60b689344645a0ea424bf7b2 100644 (file)
@@ -40,7 +40,7 @@ define <2 x i64> @sdiv_by_minus1_vec(<2 x i64> %x) {
 
 define <2 x i64> @sdiv_by_minus1_vec_undef_elt(<2 x i64> %x) {
 ; CHECK-LABEL: @sdiv_by_minus1_vec_undef_elt(
-; CHECK-NEXT:    ret <2 x i64> undef
+; CHECK-NEXT:    ret <2 x i64> poison
 ;
   %div = sdiv <2 x i64> %x, <i64 -1, i64 undef>
   ret <2 x i64> %div
@@ -514,7 +514,7 @@ define <2 x i8> @sdiv_negated_dividend_constant_divisor_vec_splat_smin(<2 x i8>
 
 define <2 x i8> @sdiv_negated_dividend_constant_divisor_vec_undef(<2 x i8> %x) {
 ; CHECK-LABEL: @sdiv_negated_dividend_constant_divisor_vec_undef(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %neg = sub nsw <2 x i8> zeroinitializer, %x
   %d = sdiv <2 x i8> %neg, <i8 -128, i8 undef>
@@ -523,8 +523,8 @@ define <2 x i8> @sdiv_negated_dividend_constant_divisor_vec_undef(<2 x i8> %x) {
 
 define <2 x i64> @sdiv_negated_dividend_constant_divisor_vec(<2 x i64> %x) {
 ; CHECK-LABEL: @sdiv_negated_dividend_constant_divisor_vec(
-; CHECK-NEXT:    [[DIV:%.*]] = sdiv <2 x i64> [[X:%.*]], <i64 -3, i64 -4>
-; CHECK-NEXT:    ret <2 x i64> [[DIV]]
+; CHECK-NEXT:    [[DIV1_NEG:%.*]] = sdiv <2 x i64> [[X:%.*]], <i64 -3, i64 -4>
+; CHECK-NEXT:    ret <2 x i64> [[DIV1_NEG]]
 ;
   %neg = sub nsw <2 x i64> zeroinitializer, %x
   %div = sdiv <2 x i64> %neg, <i64 3, i64 4>
@@ -533,8 +533,8 @@ define <2 x i64> @sdiv_negated_dividend_constant_divisor_vec(<2 x i64> %x) {
 
 define <2 x i64> @sdiv_exact_negated_dividend_constant_divisor_vec(<2 x i64> %x) {
 ; CHECK-LABEL: @sdiv_exact_negated_dividend_constant_divisor_vec(
-; CHECK-NEXT:    [[DIV:%.*]] = sdiv exact <2 x i64> [[X:%.*]], <i64 -3, i64 -4>
-; CHECK-NEXT:    ret <2 x i64> [[DIV]]
+; CHECK-NEXT:    [[DIV1_NEG:%.*]] = sdiv exact <2 x i64> [[X:%.*]], <i64 -3, i64 -4>
+; CHECK-NEXT:    ret <2 x i64> [[DIV1_NEG]]
 ;
   %neg = sub nsw <2 x i64> zeroinitializer, %x
   %div = sdiv exact <2 x i64> %neg, <i64 3, i64 4>
@@ -849,8 +849,8 @@ define <2 x i8> @udiv_common_factor_not_nuw_vec(<2 x i8> %x, <2 x i8> %y, <2 x i
 
 define i32 @test_exact_nsw_exact(i32 %x) {
 ; CHECK-LABEL: @test_exact_nsw_exact(
-; CHECK-NEXT:    [[NEG:%.*]] = sdiv exact i32 [[X:%.*]], -3
-; CHECK-NEXT:    ret i32 [[NEG]]
+; CHECK-NEXT:    [[DIV_NEG:%.*]] = sdiv exact i32 [[X:%.*]], -3
+; CHECK-NEXT:    ret i32 [[DIV_NEG]]
 ;
   %div = sdiv exact i32 %x, 3
   %neg = sub nsw i32 0, %div
@@ -859,8 +859,8 @@ define i32 @test_exact_nsw_exact(i32 %x) {
 
 define <2 x i64> @test_exact_vec(<2 x i64> %x) {
 ; CHECK-LABEL: @test_exact_vec(
-; CHECK-NEXT:    [[NEG:%.*]] = sdiv exact <2 x i64> [[X:%.*]], <i64 -3, i64 -4>
-; CHECK-NEXT:    ret <2 x i64> [[NEG]]
+; CHECK-NEXT:    [[DIV_NEG:%.*]] = sdiv exact <2 x i64> [[X:%.*]], <i64 -3, i64 -4>
+; CHECK-NEXT:    ret <2 x i64> [[DIV_NEG]]
 ;
   %div = sdiv exact <2 x i64> %x, <i64 3, i64 4>
   %neg = sub nsw <2 x i64> zeroinitializer, %div
@@ -871,8 +871,8 @@ define <2 x i64> @test_exact_vec(<2 x i64> %x) {
 
 define <2 x i8> @negate_sdiv_vec_splat(<2 x i8> %x) {
 ; CHECK-LABEL: @negate_sdiv_vec_splat(
-; CHECK-NEXT:    [[NEG:%.*]] = sdiv <2 x i8> [[X:%.*]], <i8 -42, i8 -42>
-; CHECK-NEXT:    ret <2 x i8> [[NEG]]
+; CHECK-NEXT:    [[DIV_NEG:%.*]] = sdiv <2 x i8> [[X:%.*]], <i8 -42, i8 -42>
+; CHECK-NEXT:    ret <2 x i8> [[DIV_NEG]]
 ;
   %div = sdiv <2 x i8> %x, <i8 42, i8 42>
   %neg = sub <2 x i8> zeroinitializer, %div
@@ -883,7 +883,7 @@ define <2 x i8> @negate_sdiv_vec_splat(<2 x i8> %x) {
 
 define <2 x i8> @negate_sdiv_vec_undef_elt(<2 x i8> %x) {
 ; CHECK-LABEL: @negate_sdiv_vec_undef_elt(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %div = sdiv <2 x i8> %x, <i8 undef, i8 42>
   %neg = sub <2 x i8> zeroinitializer, %div
@@ -907,8 +907,8 @@ define <2 x i8> @negate_sdiv_vec_splat_one(<2 x i8> %x) {
 define <2 x i8> @negate_sdiv_vec_splat_signed_min(<2 x i8> %x) {
 ; CHECK-LABEL: @negate_sdiv_vec_splat_signed_min(
 ; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq <2 x i8> [[X:%.*]], <i8 -128, i8 -128>
-; CHECK-NEXT:    [[NEG:%.*]] = sext <2 x i1> [[TMP1]] to <2 x i8>
-; CHECK-NEXT:    ret <2 x i8> [[NEG]]
+; CHECK-NEXT:    [[DIV_NEG:%.*]] = sext <2 x i1> [[TMP1]] to <2 x i8>
+; CHECK-NEXT:    ret <2 x i8> [[DIV_NEG]]
 ;
   %div = sdiv <2 x i8> %x, <i8 -128, i8 -128>
   %neg = sub <2 x i8> zeroinitializer, %div
@@ -956,8 +956,8 @@ define <2 x i8> @negate_sdiv_vec_signed_min_and_one_elt(<2 x i8> %x) {
 
 define i32 @test_exact_nonsw_exact(i32 %x) {
 ; CHECK-LABEL: @test_exact_nonsw_exact(
-; CHECK-NEXT:    [[NEG:%.*]] = sdiv exact i32 [[X:%.*]], -3
-; CHECK-NEXT:    ret i32 [[NEG]]
+; CHECK-NEXT:    [[DIV_NEG:%.*]] = sdiv exact i32 [[X:%.*]], -3
+; CHECK-NEXT:    ret i32 [[DIV_NEG]]
 ;
   %div = sdiv exact i32 %x, 3
   %neg = sub i32 0, %div
@@ -966,8 +966,8 @@ define i32 @test_exact_nonsw_exact(i32 %x) {
 
 define i32 @test_exact_nsw_noexact(i32 %x) {
 ; CHECK-LABEL: @test_exact_nsw_noexact(
-; CHECK-NEXT:    [[NEG:%.*]] = sdiv i32 [[X:%.*]], -3
-; CHECK-NEXT:    ret i32 [[NEG]]
+; CHECK-NEXT:    [[DIV_NEG:%.*]] = sdiv i32 [[X:%.*]], -3
+; CHECK-NEXT:    ret i32 [[DIV_NEG]]
 ;
   %div = sdiv i32 %x, 3
   %neg = sub nsw i32 0, %div
@@ -976,8 +976,8 @@ define i32 @test_exact_nsw_noexact(i32 %x) {
 
 define i32 @test_exact_nonsw_noexact(i32 %x) {
 ; CHECK-LABEL: @test_exact_nonsw_noexact(
-; CHECK-NEXT:    [[NEG:%.*]] = sdiv i32 [[X:%.*]], -3
-; CHECK-NEXT:    ret i32 [[NEG]]
+; CHECK-NEXT:    [[DIV_NEG:%.*]] = sdiv i32 [[X:%.*]], -3
+; CHECK-NEXT:    ret i32 [[DIV_NEG]]
 ;
   %div = sdiv i32 %x, 3
   %neg = sub i32 0, %div
@@ -1008,8 +1008,8 @@ define i32 @test_exact_div_one(i32 %x) {
 define i8 @test_exact_div_minSigned(i8 %x) {
 ; CHECK-LABEL: @test_exact_div_minSigned(
 ; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i8 [[X:%.*]], -128
-; CHECK-NEXT:    [[NEG:%.*]] = sext i1 [[TMP1]] to i8
-; CHECK-NEXT:    ret i8 [[NEG]]
+; CHECK-NEXT:    [[DIV_NEG:%.*]] = sext i1 [[TMP1]] to i8
+; CHECK-NEXT:    ret i8 [[DIV_NEG]]
 ;
   %div = sdiv exact i8 %x, -128
   %neg = sub nsw i8 0, %div
@@ -1040,7 +1040,7 @@ define <2 x i8> @sdiv_by_int_min_vec_splat(<2 x i8> %x) {
 
 define <2 x i8> @sdiv_by_int_min_vec_splat_undef(<2 x i8> %x) {
 ; CHECK-LABEL: @sdiv_by_int_min_vec_splat_undef(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %d = sdiv <2 x i8> %x, <i8 -128, i8 undef>
   ret <2 x i8> %d
index b68a5673faa918013112e414984002fc24ff7bc7..64f244f963835a49feb37c7c74f5a04b2ea4b343 100644 (file)
@@ -119,10 +119,10 @@ define i32 @icmp_div(i16 %a, i16 %c) {
 ; CHECK-NEXT:    br i1 [[TOBOOL]], label [[THEN:%.*]], label [[EXIT:%.*]]
 ; CHECK:       then:
 ; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i16 [[C:%.*]], 0
-; CHECK-NEXT:    [[PHITMP1:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT:    [[PHI_BO:%.*]] = sext i1 [[CMP]] to i32
 ; CHECK-NEXT:    br label [[EXIT]]
 ; CHECK:       exit:
-; CHECK-NEXT:    [[PHI:%.*]] = phi i32 [ -1, [[ENTRY:%.*]] ], [ [[PHITMP1]], [[THEN]] ]
+; CHECK-NEXT:    [[PHI:%.*]] = phi i32 [ -1, [[ENTRY:%.*]] ], [ [[PHI_BO]], [[THEN]] ]
 ; CHECK-NEXT:    ret i32 [[PHI]]
 ;
 entry:
@@ -149,8 +149,7 @@ define i32 @icmp_div2(i16 %a, i16 %c) {
 ; CHECK:       then:
 ; CHECK-NEXT:    br label [[EXIT]]
 ; CHECK:       exit:
-; CHECK-NEXT:    [[PHI:%.*]] = phi i32 [ -1, [[ENTRY:%.*]] ], [ 0, [[THEN]] ]
-; CHECK-NEXT:    ret i32 [[PHI]]
+; CHECK-NEXT:    ret i32 -1
 ;
 entry:
   %tobool = icmp eq i16 %a, 0
@@ -175,10 +174,10 @@ define i32 @icmp_div3(i16 %a, i16 %c) {
 ; CHECK-NEXT:    br i1 [[TOBOOL]], label [[THEN:%.*]], label [[EXIT:%.*]]
 ; CHECK:       then:
 ; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i16 [[C:%.*]], 0
-; CHECK-NEXT:    [[PHITMP1:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT:    [[PHI_BO:%.*]] = sext i1 [[CMP]] to i32
 ; CHECK-NEXT:    br label [[EXIT]]
 ; CHECK:       exit:
-; CHECK-NEXT:    [[PHI:%.*]] = phi i32 [ -1, [[ENTRY:%.*]] ], [ [[PHITMP1]], [[THEN]] ]
+; CHECK-NEXT:    [[PHI:%.*]] = phi i32 [ -1, [[ENTRY:%.*]] ], [ [[PHI_BO]], [[THEN]] ]
 ; CHECK-NEXT:    ret i32 [[PHI]]
 ;
 entry:
index 856eb61ba0ba03bb359c382412b556189635889a..adcbc3af39000eaa596664e5fcbdc406c9b44b80 100644 (file)
@@ -247,7 +247,7 @@ define <2 x i8> @urem_constant_op0_not_undef_lane(i8 %x) {
 
 define <2 x i8> @urem_constant_op1(i8 %x) {
 ; CHECK-LABEL: @urem_constant_op1(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %ins = insertelement <2 x i8> poison, i8 %x, i32 1
   %bo = urem <2 x i8> %ins, <i8 undef, i8 2>
@@ -289,7 +289,7 @@ define <2 x i8> @srem_constant_op0_not_undef_lane(i8 %x) {
 
 define <2 x i8> @srem_constant_op1(i8 %x) {
 ; CHECK-LABEL: @srem_constant_op1(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %ins = insertelement <2 x i8> poison, i8 %x, i32 1
   %bo = srem <2 x i8> %ins, <i8 undef, i8 2>
@@ -331,7 +331,7 @@ define <2 x i8> @udiv_constant_op0_not_undef_lane(i8 %x) {
 
 define <2 x i8> @udiv_constant_op1(i8 %x) {
 ; CHECK-LABEL: @udiv_constant_op1(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %ins = insertelement <2 x i8> poison, i8 %x, i32 1
   %bo = udiv <2 x i8> %ins, <i8 undef, i8 2>
@@ -373,7 +373,7 @@ define <2 x i8> @sdiv_constant_op0_not_undef_lane(i8 %x) {
 
 define <2 x i8> @sdiv_constant_op1(i8 %x) {
 ; CHECK-LABEL: @sdiv_constant_op1(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %ins = insertelement <2 x i8> poison, i8 %x, i32 1
   %bo = sdiv exact <2 x i8> %ins, <i8 undef, i8 2>
index 64296c9fd5ad46eabe86d7b04acd601611f82675..1d979f9e1e8127212cf05301047383f48e847227 100644 (file)
@@ -247,7 +247,7 @@ define <2 x i8> @urem_constant_op0_not_undef_lane(i8 %x) {
 
 define <2 x i8> @urem_constant_op1(i8 %x) {
 ; CHECK-LABEL: @urem_constant_op1(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %ins = insertelement <2 x i8> undef, i8 %x, i32 1
   %bo = urem <2 x i8> %ins, <i8 undef, i8 2>
@@ -289,7 +289,7 @@ define <2 x i8> @srem_constant_op0_not_undef_lane(i8 %x) {
 
 define <2 x i8> @srem_constant_op1(i8 %x) {
 ; CHECK-LABEL: @srem_constant_op1(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %ins = insertelement <2 x i8> undef, i8 %x, i32 1
   %bo = srem <2 x i8> %ins, <i8 undef, i8 2>
@@ -331,7 +331,7 @@ define <2 x i8> @udiv_constant_op0_not_undef_lane(i8 %x) {
 
 define <2 x i8> @udiv_constant_op1(i8 %x) {
 ; CHECK-LABEL: @udiv_constant_op1(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %ins = insertelement <2 x i8> undef, i8 %x, i32 1
   %bo = udiv <2 x i8> %ins, <i8 undef, i8 2>
@@ -373,7 +373,7 @@ define <2 x i8> @sdiv_constant_op0_not_undef_lane(i8 %x) {
 
 define <2 x i8> @sdiv_constant_op1(i8 %x) {
 ; CHECK-LABEL: @sdiv_constant_op1(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %ins = insertelement <2 x i8> undef, i8 %x, i32 1
   %bo = sdiv exact <2 x i8> %ins, <i8 undef, i8 2>
index 37d81f2ebf6a07a267f5032c6890b469aabb643a..8f0172e952121feef789965d2bee8432ac582fe0 100644 (file)
@@ -247,7 +247,7 @@ define i32 @test5(i32 %X, i8 %B) {
 
 define i32 @test6(i32 %A) {
 ; CHECK-LABEL: @test6(
-; CHECK-NEXT:    ret i32 undef
+; CHECK-NEXT:    ret i32 poison
 ;
   %B = srem i32 %A, 0  ;; undef
   ret i32 %B
index e19b7ad9c3db7dabf29afe1a817375d7e635b944..9c88d12206253add303619da4d34f190ed70c7b1 100644 (file)
@@ -55,7 +55,7 @@ define <2 x i8> @n4_vec_mixed(<2 x i8> %x) {
 
 define <2 x i8> @n4_vec_undef(<2 x i8> %x) {
 ; CHECK-LABEL: @n4_vec_undef(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %div = sdiv exact <2 x i8> %x, <i8 -32, i8 undef>
   ret <2 x i8> %div
index 282584b9888e1606a7cecd8866447c1bd9a18287..09c9a039fc5984c91bf0f5372ec01b24d865dd88 100644 (file)
@@ -53,7 +53,7 @@ define <2 x i8> @t4_vec(<2 x i8> %x) {
 
 define <2 x i8> @n5_vec_undef(<2 x i8> %x) {
 ; CHECK-LABEL: @n5_vec_undef(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %div = sdiv exact <2 x i8> %x, <i8 32, i8 undef>
   ret <2 x i8> %div
index a64b96882481d4d40831750578d5e768be10c9a6..6d9d74fd8199429988d78b784f773f31dbbeded2 100644 (file)
@@ -662,7 +662,7 @@ define <3 x i32> @test38_nonuniform(<3 x i32> %x) nounwind readnone {
 
 define <2 x i32> @test38_undef(<2 x i32> %x) nounwind readnone {
 ; CHECK-LABEL: @test38_undef(
-; CHECK-NEXT:    ret <2 x i32> undef
+; CHECK-NEXT:    ret <2 x i32> poison
 ;
   %rem = srem <2 x i32> %x, <i32 32, i32 undef>
   %shl = shl <2 x i32> <i32 1, i32 1>, %rem
index e16c93265ba9f5319c02ea6dcf038d39b52ec0e8..e8e5f067101a7f14eb9e878356a84b20a57a2bf4 100644 (file)
@@ -42,7 +42,7 @@ define <4 x i32> @test_v4i32_negconst(<4 x i32> %a0) {
 
 define <4 x i32> @test_v4i32_negconst_undef(<4 x i32> %a0) {
 ; CHECK-LABEL: @test_v4i32_negconst_undef(
-; CHECK-NEXT:    ret <4 x i32> undef
+; CHECK-NEXT:    ret <4 x i32> poison
 ;
   %1 = udiv <4 x i32> %a0, <i32 -3, i32 -5, i32 -7, i32 undef>
   ret <4 x i32> %1
index c9b79b219ce2e316125788c31ef12e71a14e4244..619fad8f6199a550008c08eeb15eb3b34ab8de93 100644 (file)
@@ -21,7 +21,7 @@ define <4 x i32> @test_v4i32_const_pow2(<4 x i32> %a0) {
 
 define <4 x i32> @test_v4i32_const_pow2_undef(<4 x i32> %a0) {
 ; CHECK-LABEL: @test_v4i32_const_pow2_undef(
-; CHECK-NEXT:    ret <4 x i32> undef
+; CHECK-NEXT:    ret <4 x i32> poison
 ;
   %1 = urem <4 x i32> %a0, <i32 1, i32 2, i32 4, i32 undef>
   ret <4 x i32> %1
@@ -71,7 +71,7 @@ define <4 x i32> @test_v4i32_negconst(<4 x i32> %a0) {
 
 define <4 x i32> @test_v4i32_negconst_undef(<4 x i32> %a0) {
 ; CHECK-LABEL: @test_v4i32_negconst_undef(
-; CHECK-NEXT:    ret <4 x i32> undef
+; CHECK-NEXT:    ret <4 x i32> poison
 ;
   %1 = urem <4 x i32> %a0, <i32 -3, i32 -5, i32 -7, i32 undef>
   ret <4 x i32> %1
index d2ba41c5afd73f47a857b56e09f2aec02cd76e2d..7c8efc27d3aad1fa355a3473e9920ee3fdd8636e 100644 (file)
@@ -43,10 +43,9 @@ define <2 x i8> @udiv_zero_elt_vec_constfold(<2 x i8> %x) {
   ret <2 x i8> %div
 }
 
-; TODO: instsimplify should fold these to poison
 define <2 x i8> @sdiv_zero_elt_vec(<2 x i8> %x) {
 ; CHECK-LABEL: @sdiv_zero_elt_vec(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %div = sdiv <2 x i8> %x, <i8 -42, i8 0>
   ret <2 x i8> %div
@@ -54,7 +53,7 @@ define <2 x i8> @sdiv_zero_elt_vec(<2 x i8> %x) {
 
 define <2 x i8> @udiv_zero_elt_vec(<2 x i8> %x) {
 ; CHECK-LABEL: @udiv_zero_elt_vec(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %div = udiv <2 x i8> %x, <i8 0, i8 42>
   ret <2 x i8> %div
@@ -62,7 +61,7 @@ define <2 x i8> @udiv_zero_elt_vec(<2 x i8> %x) {
 
 define <2 x i8> @sdiv_undef_elt_vec(<2 x i8> %x) {
 ; CHECK-LABEL: @sdiv_undef_elt_vec(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %div = sdiv <2 x i8> %x, <i8 -42, i8 undef>
   ret <2 x i8> %div
@@ -70,7 +69,7 @@ define <2 x i8> @sdiv_undef_elt_vec(<2 x i8> %x) {
 
 define <2 x i8> @udiv_undef_elt_vec(<2 x i8> %x) {
 ; CHECK-LABEL: @udiv_undef_elt_vec(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %div = udiv <2 x i8> %x, <i8 undef, i8 42>
   ret <2 x i8> %div
@@ -202,7 +201,6 @@ define i8 @sdiv_minusone_divisor() {
   ret i8 %v
 }
 
-; TODO: these should be poison
 define i32 @poison(i32 %x) {
 ; CHECK-LABEL: @poison(
 ; CHECK-NEXT:    ret i32 poison
@@ -211,6 +209,7 @@ define i32 @poison(i32 %x) {
   ret i32 %v
 }
 
+; TODO: this should be poison
 define i32 @poison2(i32 %x) {
 ; CHECK-LABEL: @poison2(
 ; CHECK-NEXT:    ret i32 0
@@ -221,7 +220,7 @@ define i32 @poison2(i32 %x) {
 
 define <2 x i32> @poison3(<2 x i32> %x) {
 ; CHECK-LABEL: @poison3(
-; CHECK-NEXT:    ret <2 x i32> undef
+; CHECK-NEXT:    ret <2 x i32> poison
 ;
   %v = udiv <2 x i32> %x, <i32 poison, i32 1>
   ret <2 x i32> %v
index 74b5ea7bfdc767c6862cd38c88e1bd5bbfe74310..6aaeb5c70d001b136018c1f756557e12247b3807 100644 (file)
@@ -43,10 +43,9 @@ define <2 x i8> @urem_zero_elt_vec_constfold(<2 x i8> %x) {
   ret <2 x i8> %rem
 }
 
-; TODO: instsimplify should fold these to poison
 define <2 x i8> @srem_zero_elt_vec(<2 x i8> %x) {
 ; CHECK-LABEL: @srem_zero_elt_vec(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %rem = srem <2 x i8> %x, <i8 -42, i8 0>
   ret <2 x i8> %rem
@@ -54,7 +53,7 @@ define <2 x i8> @srem_zero_elt_vec(<2 x i8> %x) {
 
 define <2 x i8> @urem_zero_elt_vec(<2 x i8> %x) {
 ; CHECK-LABEL: @urem_zero_elt_vec(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %rem = urem <2 x i8> %x, <i8 0, i8 42>
   ret <2 x i8> %rem
@@ -62,7 +61,7 @@ define <2 x i8> @urem_zero_elt_vec(<2 x i8> %x) {
 
 define <2 x i8> @srem_undef_elt_vec(<2 x i8> %x) {
 ; CHECK-LABEL: @srem_undef_elt_vec(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %rem = srem <2 x i8> %x, <i8 -42, i8 undef>
   ret <2 x i8> %rem
@@ -70,7 +69,7 @@ define <2 x i8> @srem_undef_elt_vec(<2 x i8> %x) {
 
 define <2 x i8> @urem_undef_elt_vec(<2 x i8> %x) {
 ; CHECK-LABEL: @urem_undef_elt_vec(
-; CHECK-NEXT:    ret <2 x i8> undef
+; CHECK-NEXT:    ret <2 x i8> poison
 ;
   %rem = urem <2 x i8> %x, <i8 undef, i8 42>
   ret <2 x i8> %rem
index 80780899e848d5701e13541edbae3dd3f9868d79..024ef15d31e1e2471ff8e9bc0dc2e648e3cec825 100644 (file)
@@ -188,7 +188,7 @@ define <4 x i8> @test19(<4 x i8> %a) {
 
 define i32 @test20(i32 %a) {
 ; CHECK-LABEL: @test20(
-; CHECK-NEXT:    ret i32 undef
+; CHECK-NEXT:    ret i32 poison
 ;
   %b = udiv i32 %a, 0
   ret i32 %b
@@ -196,7 +196,7 @@ define i32 @test20(i32 %a) {
 
 define <2 x i32> @test20vec(<2 x i32> %a) {
 ; CHECK-LABEL: @test20vec(
-; CHECK-NEXT:    ret <2 x i32> undef
+; CHECK-NEXT:    ret <2 x i32> poison
 ;
   %b = udiv <2 x i32> %a, zeroinitializer
   ret <2 x i32> %b
@@ -204,7 +204,7 @@ define <2 x i32> @test20vec(<2 x i32> %a) {
 
 define i32 @test21(i32 %a) {
 ; CHECK-LABEL: @test21(
-; CHECK-NEXT:    ret i32 undef
+; CHECK-NEXT:    ret i32 poison
 ;
   %b = sdiv i32 %a, 0
   ret i32 %b
@@ -212,7 +212,7 @@ define i32 @test21(i32 %a) {
 
 define <2 x i32> @test21vec(<2 x i32> %a) {
 ; CHECK-LABEL: @test21vec(
-; CHECK-NEXT:    ret <2 x i32> undef
+; CHECK-NEXT:    ret <2 x i32> poison
 ;
   %b = sdiv <2 x i32> %a, zeroinitializer
   ret <2 x i32> %b
@@ -348,7 +348,7 @@ define i32 @test37() {
 
 define i32 @test38(i32 %a) {
 ; CHECK-LABEL: @test38(
-; CHECK-NEXT:    ret i32 undef
+; CHECK-NEXT:    ret i32 poison
 ;
   %b = udiv i32 %a, undef
   ret i32 %b
index 702ab0db22191b39f46825c50c858673627ce0e9..8275f4a19e308629e25d48ba7b3d6b40665ff506 100644 (file)
@@ -425,7 +425,7 @@ define <8 x i32> @sdiv_v8i32_undefs(<8 x i32> %a) {
 ; CHECK-NEXT:    [[AB5:%.*]] = sdiv i32 [[A5]], 4
 ; CHECK-NEXT:    [[AB6:%.*]] = sdiv i32 [[A6]], 8
 ; CHECK-NEXT:    [[AB7:%.*]] = sdiv i32 [[A7]], 16
-; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <8 x i32> <i32 undef, i32 poison, i32 poison, i32 poison, i32 undef, i32 poison, i32 poison, i32 poison>, i32 [[AB1]], i32 1
+; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <8 x i32> <i32 undef, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>, i32 [[AB1]], i32 1
 ; CHECK-NEXT:    [[TMP2:%.*]] = insertelement <8 x i32> [[TMP1]], i32 [[AB2]], i32 2
 ; CHECK-NEXT:    [[R4:%.*]] = insertelement <8 x i32> [[TMP2]], i32 [[AB3]], i32 3
 ; CHECK-NEXT:    [[R5:%.*]] = insertelement <8 x i32> [[R4]], i32 [[AB5]], i32 5