Revert "[InstCombine] Return instruction from replaceUse()"

This reverts commit 27c4e23310.

I think I made a mistake with the use in RemoveConditionFromAssume(),
because the instruction being changed is not the current one, but
the next assume. Revert the change for now.
This commit is contained in:
Nikita Popov 2023-03-14 17:45:38 +01:00
parent b2fad8027a
commit fdda602c04
3 changed files with 8 additions and 7 deletions

View File

@ -446,10 +446,9 @@ public:
}
/// Replace use and add the previously used value to the worklist.
Instruction *replaceUse(Use &U, Value *NewValue) {
void replaceUse(Use &U, Value *NewValue) {
Worklist.addValue(U);
U = NewValue;
return cast<Instruction>(U.getUser());
}
/// Combiner aware instruction erasure.

View File

@ -2436,8 +2436,8 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
assert(isa<AssumeInst>(Assume));
if (isAssumeWithEmptyBundle(*cast<AssumeInst>(II)))
return eraseInstFromFunction(CI);
return replaceUse(II->getOperandUse(0),
ConstantInt::getTrue(II->getContext()));
replaceUse(II->getOperandUse(0), ConstantInt::getTrue(II->getContext()));
return nullptr;
};
// Remove an assume if it is followed by an identical assume.
// TODO: Do we need this? Unless there are conflicting assumptions, the
@ -2964,8 +2964,10 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
}
// Can remove shuffle iff just shuffled elements, no repeats, undefs, or
// other changes.
if (UsedIndices.all())
return replaceUse(II->getOperandUse(ArgIdx), V);
if (UsedIndices.all()) {
replaceUse(II->getOperandUse(ArgIdx), V);
return nullptr;
}
break;
}
case Intrinsic::is_fpclass: {

View File

@ -1251,7 +1251,7 @@ static bool replaceInInstruction(Value *V, Value *Old, Value *New,
bool Changed = false;
for (Use &U : I->operands()) {
if (U == Old) {
IC.addToWorklist(IC.replaceUse(U, New));
IC.replaceUse(U, New);
Changed = true;
} else {
Changed |= replaceInInstruction(U, Old, New, IC, Depth + 1);