[llvm] fdda602 - Revert "[InstCombine] Return instruction from replaceUse()"
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 14 09:46:42 PDT 2023
Author: Nikita Popov
Date: 2023-03-14T17:46:33+01:00
New Revision: fdda602c04e43f7be8820996d3161abb71bec67b
URL: https://github.com/llvm/llvm-project/commit/fdda602c04e43f7be8820996d3161abb71bec67b
DIFF: https://github.com/llvm/llvm-project/commit/fdda602c04e43f7be8820996d3161abb71bec67b.diff
LOG: Revert "[InstCombine] Return instruction from replaceUse()"
This reverts commit 27c4e233104ba765cd986b3f8b0dcd3a6c3a9f89.
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.
Added:
Modified:
llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
index 4236544d3ecc4..a876385581e72 100644
--- a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
+++ b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
@@ -446,10 +446,9 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
}
/// 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.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 94d3f99156852..01249613d47a0 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -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: {
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index fbaf798a0cea8..1f2441bc9fcf9 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -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);
More information about the llvm-commits
mailing list