[llvm] 09d6fa7 - [InstCombine] Handle use count decrement in more cases
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 14 01:03:17 PDT 2023
Author: Nikita Popov
Date: 2023-06-14T10:03:09+02:00
New Revision: 09d6fa7968e8299c1b9348dc66c1ead477fb5580
URL: https://github.com/llvm/llvm-project/commit/09d6fa7968e8299c1b9348dc66c1ead477fb5580
DIFF: https://github.com/llvm/llvm-project/commit/09d6fa7968e8299c1b9348dc66c1ead477fb5580.diff
LOG: [InstCombine] Handle use count decrement in more cases
These two helpers also decrement the use count of the replaced
operand, so give them the same treatment as eraseInstruction().
Added:
Modified:
llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
index 21fbb114ab082..5569bc90caa69 100644
--- a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
+++ b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
@@ -441,15 +441,17 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
/// Replace operand of instruction and add old operand to the worklist.
Instruction *replaceOperand(Instruction &I, unsigned OpNum, Value *V) {
- Worklist.addValue(I.getOperand(OpNum));
+ Value *OldOp = I.getOperand(OpNum);
I.setOperand(OpNum, V);
+ Worklist.handleUseCountDecrement(OldOp);
return &I;
}
/// Replace use and add the previously used value to the worklist.
void replaceUse(Use &U, Value *NewValue) {
- Worklist.addValue(U);
+ Value *OldOp = U;
U = NewValue;
+ Worklist.handleUseCountDecrement(OldOp);
}
/// Combiner aware instruction erasure.
More information about the llvm-commits
mailing list