Skip to content

Commit cb6240d

Browse files
committed
[BDCE] Also drop poison-generating metadata
The comment was incorrect: !range also applies to calls, and we do need to drop it in some cases.
1 parent b437014 commit cb6240d

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

llvm/lib/Transforms/Scalar/BDCE.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@ static void clearAssumptionsOfUsers(Instruction *I, DemandedBits &DB) {
7575
Instruction *J = WorkList.pop_back_val();
7676

7777
// NSW, NUW, and exact are based on operands that might have changed.
78-
J->dropPoisonGeneratingFlags();
78+
J->dropPoisonGeneratingFlagsAndMetadata();
7979

80-
// We do not have to worry about llvm.assume or range metadata:
81-
// 1. llvm.assume demands its operand, so trivializing can't change it.
82-
// 2. range metadata only applies to memory accesses which demand all bits.
80+
// We do not have to worry about llvm.assume, because it demands its
81+
// operand, so trivializing can't change it.
8382

8483
// If all bits of a user are demanded, then we know that nothing below
8584
// that in the def-use chain needs to be changed.

llvm/test/Transforms/BDCE/invalidate-assumptions.ll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ define i32 @disjoint_indirect(i64 %x) {
124124
define i32 @range(i32 %x) {
125125
; CHECK-LABEL: define i32 @range(
126126
; CHECK-SAME: i32 [[X:%.*]]) {
127-
; CHECK-NEXT: [[UMIN:%.*]] = call i32 @llvm.umin.i32(i32 [[X]], i32 100), !range [[RNG0:![0-9]+]]
127+
; CHECK-NEXT: [[UMIN:%.*]] = call i32 @llvm.umin.i32(i32 [[X]], i32 100)
128128
; CHECK-NEXT: [[AND:%.*]] = and i32 [[UMIN]], -2
129129
; CHECK-NEXT: ret i32 [[AND]]
130130
;
@@ -133,6 +133,3 @@ define i32 @range(i32 %x) {
133133
%and = and i32 %umin, -2
134134
ret i32 %and
135135
}
136-
;.
137-
; CHECK: [[RNG0]] = !{i32 1, i32 101}
138-
;.

0 commit comments

Comments
 (0)