}
/// Replace use and add the previously used value to the worklist.
- void replaceUse(Use &U, Value *NewValue) {
+ Instruction *replaceUse(Use &U, Value *NewValue) {
Worklist.addValue(U);
U = NewValue;
+ return cast<Instruction>(U.getUser());
}
/// Combiner aware instruction erasure.
assert(isa<AssumeInst>(Assume));
if (isAssumeWithEmptyBundle(*cast<AssumeInst>(II)))
return eraseInstFromFunction(CI);
- replaceUse(II->getOperandUse(0), ConstantInt::getTrue(II->getContext()));
- return nullptr;
+ return replaceUse(II->getOperandUse(0),
+ ConstantInt::getTrue(II->getContext()));
};
// Remove an assume if it is followed by an identical assume.
// TODO: Do we need this? Unless there are conflicting assumptions, the
}
// Can remove shuffle iff just shuffled elements, no repeats, undefs, or
// other changes.
- if (UsedIndices.all()) {
- replaceUse(II->getOperandUse(ArgIdx), V);
- return nullptr;
- }
+ if (UsedIndices.all())
+ return replaceUse(II->getOperandUse(ArgIdx), V);
break;
}
case Intrinsic::is_fpclass: {
bool Changed = false;
for (Use &U : I->operands()) {
if (U == Old) {
- IC.replaceUse(U, New);
+ IC.addToWorklist(IC.replaceUse(U, New));
Changed = true;
} else {
Changed |= replaceInInstruction(U, Old, New, IC, Depth + 1);