llvm.org GIT mirror llvm / da74d6f
[BDCE] Remove instructions without demanded bits If an instruction has no demanded bits, remove it directly during BDCE, instead of leaving it for something else to clean up. Differential Revision: https://reviews.llvm.org/D56185 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350257 91177308-0d34-0410-b5e6-96231b3b80d8 Nikita Popov 8 months ago
3 changed file(s) with 8 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
9595 if (I.mayHaveSideEffects() && I.use_empty())
9696 continue;
9797
98 // Remove instructions not reached during analysis.
99 if (DB.isInstructionDead(&I)) {
98 // Remove instructions that are dead, either because they were not reached
99 // during analysis or have no demanded bits.
100 if (DB.isInstructionDead(&I) ||
101 (I.getType()->isIntOrIntVectorTy() &&
102 DB.getDemandedBits(&I).isNullValue() &&
103 wouldInstructionBeTriviallyDead(&I))) {
100104 salvageDebugInfo(I);
101105 Worklist.push_back(&I);
102106 I.dropAllReferences();
88
99 define i1 @PR33695(i1 %b, i8 %x) {
1010 ; CHECK-LABEL: @PR33695(
11 ; CHECK-NEXT: [[SETBIT:%.*]] = or i8 [[X:%.*]], 64
1211 ; CHECK-NEXT: [[LITTLE_NUMBER:%.*]] = zext i1 [[B:%.*]] to i8
1312 ; CHECK-NEXT: [[BIG_NUMBER:%.*]] = shl i8 0, 1
1413 ; CHECK-NEXT: [[SUB:%.*]] = sub i8 [[BIG_NUMBER]], [[LITTLE_NUMBER]]
2827
2928 define i64 @PR34037(i64 %m, i32 %r, i64 %j, i1 %b, i32 %k, i64 %p) {
3029 ; CHECK-LABEL: @PR34037(
31 ; CHECK-NEXT: [[CONV:%.*]] = zext i32 [[R:%.*]] to i64
32 ; CHECK-NEXT: [[AND:%.*]] = and i64 [[M:%.*]], 0
33 ; CHECK-NEXT: [[NEG:%.*]] = xor i64 0, 34359738367
34 ; CHECK-NEXT: [[OR:%.*]] = or i64 [[J:%.*]], 0
3530 ; CHECK-NEXT: [[SHL:%.*]] = shl i64 0, 29
3631 ; CHECK-NEXT: [[CONV1:%.*]] = select i1 [[B:%.*]], i64 7, i64 0
3732 ; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[SHL]], [[CONV1]]
6358
6459 define i1 @poison_on_call_user_is_ok(i1 %b, i8 %x) {
6560 ; CHECK-LABEL: @poison_on_call_user_is_ok(
66 ; CHECK-NEXT: [[SETBIT:%.*]] = or i8 [[X:%.*]], 64
6761 ; CHECK-NEXT: [[LITTLE_NUMBER:%.*]] = zext i1 [[B:%.*]] to i8
6862 ; CHECK-NEXT: [[BIG_NUMBER:%.*]] = shl i8 0, 1
6963 ; CHECK-NEXT: [[SUB:%.*]] = sub i8 [[BIG_NUMBER]], [[LITTLE_NUMBER]]
44
55 define <2 x i32> @test_basic(<2 x i32> %a, <2 x i32> %b) {
66 ; CHECK-LABEL: @test_basic(
7 ; CHECK-NEXT: [[A2:%.*]] = add <2 x i32> [[A:%.*]],
87 ; CHECK-NEXT: [[A3:%.*]] = and <2 x i32> zeroinitializer,
98 ; CHECK-NEXT: [[B2:%.*]] = add <2 x i32> [[B:%.*]],
109 ; CHECK-NEXT: [[B3:%.*]] = and <2 x i32> [[B2]],
2423 ; Going vector -> scalar
2524 define i32 @test_extractelement(<2 x i32> %a, <2 x i32> %b) {
2625 ; CHECK-LABEL: @test_extractelement(
27 ; CHECK-NEXT: [[A2:%.*]] = add <2 x i32> [[A:%.*]],
2826 ; CHECK-NEXT: [[A3:%.*]] = and <2 x i32> zeroinitializer,
2927 ; CHECK-NEXT: [[B2:%.*]] = add <2 x i32> [[B:%.*]],
3028 ; CHECK-NEXT: [[B3:%.*]] = and <2 x i32> [[B2]],
4644 ; Going scalar -> vector
4745 define <2 x i32> @test_insertelement(i32 %a, i32 %b) {
4846 ; CHECK-LABEL: @test_insertelement(
49 ; CHECK-NEXT: [[X:%.*]] = insertelement <2 x i32> undef, i32 [[A:%.*]], i32 0
50 ; CHECK-NEXT: [[X2:%.*]] = insertelement <2 x i32> zeroinitializer, i32 [[B:%.*]], i32 1
5147 ; CHECK-NEXT: [[X3:%.*]] = and <2 x i32> zeroinitializer,
52 ; CHECK-NEXT: [[Y:%.*]] = insertelement <2 x i32> undef, i32 [[B]], i32 0
53 ; CHECK-NEXT: [[Y2:%.*]] = insertelement <2 x i32> [[Y]], i32 [[A]], i32 1
48 ; CHECK-NEXT: [[Y:%.*]] = insertelement <2 x i32> undef, i32 [[B:%.*]], i32 0
49 ; CHECK-NEXT: [[Y2:%.*]] = insertelement <2 x i32> [[Y]], i32 [[A:%.*]], i32 1
5450 ; CHECK-NEXT: [[Y3:%.*]] = and <2 x i32> [[Y2]],
5551 ; CHECK-NEXT: [[Z:%.*]] = or <2 x i32> [[X3]], [[Y3]]
5652 ; CHECK-NEXT: [[U:%.*]] = ashr <2 x i32> [[Z]],
9086 ; Assumption invalidation (adapted from invalidate-assumptions.ll)
9187 define <2 x i1> @test_assumption_invalidation(<2 x i1> %b, <2 x i8> %x) {
9288 ; CHECK-LABEL: @test_assumption_invalidation(
93 ; CHECK-NEXT: [[SETBIT:%.*]] = or <2 x i8> [[X:%.*]],
9489 ; CHECK-NEXT: [[LITTLE_NUMBER:%.*]] = zext <2 x i1> [[B:%.*]] to <2 x i8>
9590 ; CHECK-NEXT: [[BIG_NUMBER:%.*]] = shl <2 x i8> zeroinitializer,
9691 ; CHECK-NEXT: [[SUB:%.*]] = sub <2 x i8> [[BIG_NUMBER]], [[LITTLE_NUMBER]]