forked from OSchip/llvm-project
[InstCombine] Improve simplify demanded bits worklist management
This fixes a small mistake from D72944: The worklist add should happen before assigning the new operand, not after. In case an actual replacement happens, the old operand needs to be added for DCE. If no actual replacement happens, then old/new are the same, so it doesn't matter. This drops one iteration from the annotated test case.
This commit is contained in:
parent
0e3e242209
commit
b178555318
|
@ -87,9 +87,9 @@ bool InstCombiner::SimplifyDemandedBits(Instruction *I, unsigned OpNo,
|
||||||
Value *NewVal = SimplifyDemandedUseBits(U.get(), DemandedMask, Known,
|
Value *NewVal = SimplifyDemandedUseBits(U.get(), DemandedMask, Known,
|
||||||
Depth, I);
|
Depth, I);
|
||||||
if (!NewVal) return false;
|
if (!NewVal) return false;
|
||||||
U = NewVal;
|
// Add the old operand back to the worklist.
|
||||||
// Add the simplified instruction back to the worklist.
|
|
||||||
Worklist.addValue(U.get());
|
Worklist.addValue(U.get());
|
||||||
|
U = NewVal;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; RUN: opt -instcombine -S < %s | FileCheck %s
|
; RUN: opt -instcombine -instcombine-infinite-loop-threshold=3 -S < %s | FileCheck %s
|
||||||
|
|
||||||
; <rdar://problem/8606771>
|
; <rdar://problem/8606771>
|
||||||
define i32 @main(i32 %argc) {
|
define i32 @main(i32 %argc) {
|
||||||
|
|
Loading…
Reference in New Issue