diff --git a/llvm/lib/Transforms/Scalar/BDCE.cpp b/llvm/lib/Transforms/Scalar/BDCE.cpp --- a/llvm/lib/Transforms/Scalar/BDCE.cpp +++ b/llvm/lib/Transforms/Scalar/BDCE.cpp @@ -142,11 +142,7 @@ LLVM_DEBUG(dbgs() << "BDCE: Trivializing: " << U << " (all bits dead)\n"); clearAssumptionsOfUsers(&I, DB); - - // FIXME: In theory we could substitute undef here instead of zero. - // This should be reconsidered once we settle on the semantics of - // undef, poison, etc. - U.set(ConstantInt::get(U->getType(), 0)); + U.set(UndefValue::get(U->getType())); ++NumSimplified; Changed = true; } diff --git a/llvm/test/Transforms/BDCE/dead-uses.ll b/llvm/test/Transforms/BDCE/dead-uses.ll --- a/llvm/test/Transforms/BDCE/dead-uses.ll +++ b/llvm/test/Transforms/BDCE/dead-uses.ll @@ -10,7 +10,7 @@ define i32 @pr39771_fshr_multi_use_instr(i32 %a) { ; CHECK-LABEL: @pr39771_fshr_multi_use_instr( ; CHECK-NEXT: [[X:%.*]] = or i32 [[A:%.*]], 0 -; CHECK-NEXT: [[B:%.*]] = tail call i32 @llvm.fshr.i32(i32 0, i32 [[X]], i32 1) +; CHECK-NEXT: [[B:%.*]] = tail call i32 @llvm.fshr.i32(i32 undef, i32 [[X]], i32 1) ; CHECK-NEXT: [[C:%.*]] = lshr i32 [[B]], 23 ; CHECK-NEXT: [[D:%.*]] = xor i32 [[C]], [[B]] ; CHECK-NEXT: [[E:%.*]] = and i32 [[D]], 31 @@ -28,7 +28,7 @@ define <2 x i32> @pr39771_fshr_multi_use_instr_vec(<2 x i32> %a) { ; CHECK-LABEL: @pr39771_fshr_multi_use_instr_vec( ; CHECK-NEXT: [[X:%.*]] = or <2 x i32> [[A:%.*]], zeroinitializer -; CHECK-NEXT: [[B:%.*]] = tail call <2 x i32> @llvm.fshr.v2i32(<2 x i32> zeroinitializer, <2 x i32> [[X]], <2 x i32> ) +; CHECK-NEXT: [[B:%.*]] = tail call <2 x i32> @llvm.fshr.v2i32(<2 x i32> undef, <2 x i32> [[X]], <2 x i32> ) ; CHECK-NEXT: [[C:%.*]] = lshr <2 x i32> [[B]], ; CHECK-NEXT: [[D:%.*]] = xor <2 x i32> [[C]], [[B]] ; CHECK-NEXT: [[E:%.*]] = and <2 x i32> [[D]], @@ -45,7 +45,7 @@ ; First fshr operand is dead, but it comes from an argument, not instruction. define i32 @pr39771_fshr_multi_use_arg(i32 %a) { ; CHECK-LABEL: @pr39771_fshr_multi_use_arg( -; CHECK-NEXT: [[B:%.*]] = tail call i32 @llvm.fshr.i32(i32 0, i32 [[A:%.*]], i32 1) +; CHECK-NEXT: [[B:%.*]] = tail call i32 @llvm.fshr.i32(i32 undef, i32 [[A:%.*]], i32 1) ; CHECK-NEXT: [[C:%.*]] = lshr i32 [[B]], 23 ; CHECK-NEXT: [[D:%.*]] = xor i32 [[C]], [[B]] ; CHECK-NEXT: [[E:%.*]] = and i32 [[D]], 31 @@ -61,7 +61,7 @@ define i32 @pr39771_expanded_fshr_multi_use(i32 %a) { ; CHECK-LABEL: @pr39771_expanded_fshr_multi_use( ; CHECK-NEXT: [[TMP:%.*]] = lshr i32 [[A:%.*]], 1 -; CHECK-NEXT: [[TMP2:%.*]] = shl i32 0, 31 +; CHECK-NEXT: [[TMP2:%.*]] = shl i32 undef, 31 ; CHECK-NEXT: [[B:%.*]] = or i32 [[TMP]], [[TMP2]] ; CHECK-NEXT: [[C:%.*]] = lshr i32 [[B]], 23 ; CHECK-NEXT: [[D:%.*]] = xor i32 [[C]], [[B]] diff --git a/llvm/test/Transforms/BDCE/intrinsics.ll b/llvm/test/Transforms/BDCE/intrinsics.ll --- a/llvm/test/Transforms/BDCE/intrinsics.ll +++ b/llvm/test/Transforms/BDCE/intrinsics.ll @@ -8,8 +8,8 @@ define i8 @umax(i8 %x, i8 %y, i1 %a, i1 %b) { ; CHECK-LABEL: @umax( -; CHECK-NEXT: [[A2:%.*]] = zext i1 false to i8 -; CHECK-NEXT: [[B2:%.*]] = zext i1 false to i8 +; CHECK-NEXT: [[A2:%.*]] = zext i1 undef to i8 +; CHECK-NEXT: [[B2:%.*]] = zext i1 undef to i8 ; CHECK-NEXT: [[X2:%.*]] = or i8 [[X:%.*]], [[A2]] ; CHECK-NEXT: [[Y2:%.*]] = or i8 [[Y:%.*]], [[B2]] ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[X2]], i8 [[Y2]]) @@ -27,8 +27,8 @@ define i8 @umin(i8 %x, i8 %y, i1 %a, i1 %b) { ; CHECK-LABEL: @umin( -; CHECK-NEXT: [[A2:%.*]] = zext i1 false to i8 -; CHECK-NEXT: [[B2:%.*]] = zext i1 false to i8 +; CHECK-NEXT: [[A2:%.*]] = zext i1 undef to i8 +; CHECK-NEXT: [[B2:%.*]] = zext i1 undef to i8 ; CHECK-NEXT: [[X2:%.*]] = or i8 [[X:%.*]], [[A2]] ; CHECK-NEXT: [[Y2:%.*]] = or i8 [[Y:%.*]], [[B2]] ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[X2]], i8 [[Y2]]) @@ -46,8 +46,8 @@ define i8 @smax(i8 %x, i8 %y, i1 %a, i1 %b) { ; CHECK-LABEL: @smax( -; CHECK-NEXT: [[A2:%.*]] = zext i1 false to i8 -; CHECK-NEXT: [[B2:%.*]] = zext i1 false to i8 +; CHECK-NEXT: [[A2:%.*]] = zext i1 undef to i8 +; CHECK-NEXT: [[B2:%.*]] = zext i1 undef to i8 ; CHECK-NEXT: [[X2:%.*]] = or i8 [[X:%.*]], [[A2]] ; CHECK-NEXT: [[Y2:%.*]] = or i8 [[Y:%.*]], [[B2]] ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[X2]], i8 [[Y2]]) @@ -65,8 +65,8 @@ define i8 @smin(i8 %x, i8 %y, i1 %a, i1 %b) { ; CHECK-LABEL: @smin( -; CHECK-NEXT: [[A2:%.*]] = zext i1 false to i8 -; CHECK-NEXT: [[B2:%.*]] = zext i1 false to i8 +; CHECK-NEXT: [[A2:%.*]] = zext i1 undef to i8 +; CHECK-NEXT: [[B2:%.*]] = zext i1 undef to i8 ; CHECK-NEXT: [[X2:%.*]] = or i8 [[X:%.*]], [[A2]] ; CHECK-NEXT: [[Y2:%.*]] = or i8 [[Y:%.*]], [[B2]] ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[X2]], i8 [[Y2]]) diff --git a/llvm/test/Transforms/BDCE/invalidate-assumptions.ll b/llvm/test/Transforms/BDCE/invalidate-assumptions.ll --- a/llvm/test/Transforms/BDCE/invalidate-assumptions.ll +++ b/llvm/test/Transforms/BDCE/invalidate-assumptions.ll @@ -10,7 +10,7 @@ define i1 @PR33695(i1 %b, i8 %x) { ; CHECK-LABEL: @PR33695( ; CHECK-NEXT: [[LITTLE_NUMBER:%.*]] = zext i1 [[B:%.*]] to i8 -; CHECK-NEXT: [[BIG_NUMBER:%.*]] = shl i8 0, 1 +; CHECK-NEXT: [[BIG_NUMBER:%.*]] = shl i8 undef, 1 ; CHECK-NEXT: [[SUB:%.*]] = sub i8 [[BIG_NUMBER]], [[LITTLE_NUMBER]] ; CHECK-NEXT: [[TRUNC:%.*]] = trunc i8 [[SUB]] to i1 ; CHECK-NEXT: ret i1 [[TRUNC]] @@ -28,7 +28,7 @@ define i64 @PR34037(i64 %m, i32 %r, i64 %j, i1 %b, i32 %k, i64 %p) { ; CHECK-LABEL: @PR34037( -; CHECK-NEXT: [[SHL:%.*]] = shl i64 0, 29 +; CHECK-NEXT: [[SHL:%.*]] = shl i64 undef, 29 ; CHECK-NEXT: [[CONV1:%.*]] = select i1 [[B:%.*]], i64 7, i64 0 ; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[SHL]], [[CONV1]] ; CHECK-NEXT: [[CONV2:%.*]] = zext i32 [[K:%.*]] to i64 @@ -60,7 +60,7 @@ define i1 @poison_on_call_user_is_ok(i1 %b, i8 %x) { ; CHECK-LABEL: @poison_on_call_user_is_ok( ; CHECK-NEXT: [[LITTLE_NUMBER:%.*]] = zext i1 [[B:%.*]] to i8 -; CHECK-NEXT: [[BIG_NUMBER:%.*]] = shl i8 0, 1 +; CHECK-NEXT: [[BIG_NUMBER:%.*]] = shl i8 undef, 1 ; CHECK-NEXT: [[SUB:%.*]] = sub i8 [[BIG_NUMBER]], [[LITTLE_NUMBER]] ; CHECK-NEXT: [[TRUNC:%.*]] = trunc i8 [[SUB]] to i1 ; CHECK-NEXT: [[CALL_RESULT:%.*]] = call i1 @foo(i1 [[TRUNC]]) @@ -85,7 +85,7 @@ define void @PR34179(ptr %a) { ; CHECK-LABEL: @PR34179( -; CHECK-NEXT: [[T0:%.*]] = load volatile i32, ptr [[A:%.*]] +; CHECK-NEXT: [[T0:%.*]] = load volatile i32, ptr [[A:%.*]], align 4 ; CHECK-NEXT: ret void ; %t0 = load volatile i32, ptr %a diff --git a/llvm/test/Transforms/BDCE/vectors-inseltpoison.ll b/llvm/test/Transforms/BDCE/vectors-inseltpoison.ll --- a/llvm/test/Transforms/BDCE/vectors-inseltpoison.ll +++ b/llvm/test/Transforms/BDCE/vectors-inseltpoison.ll @@ -5,7 +5,7 @@ define <2 x i32> @test_basic(<2 x i32> %a, <2 x i32> %b) { ; CHECK-LABEL: @test_basic( -; CHECK-NEXT: [[A3:%.*]] = and <2 x i32> zeroinitializer, +; CHECK-NEXT: [[A3:%.*]] = and <2 x i32> undef, ; CHECK-NEXT: [[B2:%.*]] = add <2 x i32> [[B:%.*]], ; CHECK-NEXT: [[B3:%.*]] = and <2 x i32> [[B2]], ; CHECK-NEXT: [[C:%.*]] = or <2 x i32> [[A3]], [[B3]] @@ -24,7 +24,7 @@ ; Going vector -> scalar define i32 @test_extractelement(<2 x i32> %a, <2 x i32> %b) { ; CHECK-LABEL: @test_extractelement( -; CHECK-NEXT: [[A3:%.*]] = and <2 x i32> zeroinitializer, +; CHECK-NEXT: [[A3:%.*]] = and <2 x i32> undef, ; CHECK-NEXT: [[B2:%.*]] = add <2 x i32> [[B:%.*]], ; CHECK-NEXT: [[B3:%.*]] = and <2 x i32> [[B2]], ; CHECK-NEXT: [[C:%.*]] = or <2 x i32> [[A3]], [[B3]] @@ -45,7 +45,7 @@ ; Going scalar -> vector define <2 x i32> @test_insertelement(i32 %a, i32 %b) { ; CHECK-LABEL: @test_insertelement( -; CHECK-NEXT: [[X3:%.*]] = and <2 x i32> zeroinitializer, +; CHECK-NEXT: [[X3:%.*]] = and <2 x i32> undef, ; CHECK-NEXT: [[Y:%.*]] = insertelement <2 x i32> poison, i32 [[B:%.*]], i32 0 ; CHECK-NEXT: [[Y2:%.*]] = insertelement <2 x i32> [[Y]], i32 [[A:%.*]], i32 1 ; CHECK-NEXT: [[Y3:%.*]] = and <2 x i32> [[Y2]], @@ -88,7 +88,7 @@ define <2 x i1> @test_assumption_invalidation(<2 x i1> %b, <2 x i8> %x) { ; CHECK-LABEL: @test_assumption_invalidation( ; CHECK-NEXT: [[LITTLE_NUMBER:%.*]] = zext <2 x i1> [[B:%.*]] to <2 x i8> -; CHECK-NEXT: [[BIG_NUMBER:%.*]] = shl <2 x i8> zeroinitializer, +; CHECK-NEXT: [[BIG_NUMBER:%.*]] = shl <2 x i8> undef, ; CHECK-NEXT: [[SUB:%.*]] = sub <2 x i8> [[BIG_NUMBER]], [[LITTLE_NUMBER]] ; CHECK-NEXT: [[TRUNC:%.*]] = trunc <2 x i8> [[SUB]] to <2 x i1> ; CHECK-NEXT: ret <2 x i1> [[TRUNC]] diff --git a/llvm/test/Transforms/BDCE/vectors.ll b/llvm/test/Transforms/BDCE/vectors.ll --- a/llvm/test/Transforms/BDCE/vectors.ll +++ b/llvm/test/Transforms/BDCE/vectors.ll @@ -5,7 +5,7 @@ define <2 x i32> @test_basic(<2 x i32> %a, <2 x i32> %b) { ; CHECK-LABEL: @test_basic( -; CHECK-NEXT: [[A3:%.*]] = and <2 x i32> zeroinitializer, +; CHECK-NEXT: [[A3:%.*]] = and <2 x i32> undef, ; CHECK-NEXT: [[B2:%.*]] = add <2 x i32> [[B:%.*]], ; CHECK-NEXT: [[B3:%.*]] = and <2 x i32> [[B2]], ; CHECK-NEXT: [[C:%.*]] = or <2 x i32> [[A3]], [[B3]] @@ -24,7 +24,7 @@ ; Going vector -> scalar define i32 @test_extractelement(<2 x i32> %a, <2 x i32> %b) { ; CHECK-LABEL: @test_extractelement( -; CHECK-NEXT: [[A3:%.*]] = and <2 x i32> zeroinitializer, +; CHECK-NEXT: [[A3:%.*]] = and <2 x i32> undef, ; CHECK-NEXT: [[B2:%.*]] = add <2 x i32> [[B:%.*]], ; CHECK-NEXT: [[B3:%.*]] = and <2 x i32> [[B2]], ; CHECK-NEXT: [[C:%.*]] = or <2 x i32> [[A3]], [[B3]] @@ -45,7 +45,7 @@ ; Going scalar -> vector define <2 x i32> @test_insertelement(i32 %a, i32 %b) { ; CHECK-LABEL: @test_insertelement( -; CHECK-NEXT: [[X3:%.*]] = and <2 x i32> zeroinitializer, +; CHECK-NEXT: [[X3:%.*]] = and <2 x i32> undef, ; CHECK-NEXT: [[Y:%.*]] = insertelement <2 x i32> undef, i32 [[B:%.*]], i32 0 ; CHECK-NEXT: [[Y2:%.*]] = insertelement <2 x i32> [[Y]], i32 [[A:%.*]], i32 1 ; CHECK-NEXT: [[Y3:%.*]] = and <2 x i32> [[Y2]], @@ -88,7 +88,7 @@ define <2 x i1> @test_assumption_invalidation(<2 x i1> %b, <2 x i8> %x) { ; CHECK-LABEL: @test_assumption_invalidation( ; CHECK-NEXT: [[LITTLE_NUMBER:%.*]] = zext <2 x i1> [[B:%.*]] to <2 x i8> -; CHECK-NEXT: [[BIG_NUMBER:%.*]] = shl <2 x i8> zeroinitializer, +; CHECK-NEXT: [[BIG_NUMBER:%.*]] = shl <2 x i8> undef, ; CHECK-NEXT: [[SUB:%.*]] = sub <2 x i8> [[BIG_NUMBER]], [[LITTLE_NUMBER]] ; CHECK-NEXT: [[TRUNC:%.*]] = trunc <2 x i8> [[SUB]] to <2 x i1> ; CHECK-NEXT: ret <2 x i1> [[TRUNC]]