[llvm] 4b35c81 - [InstCombine] Use replaceOperand() in div transforms
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 10:55:12 PDT 2020
Author: Nikita Popov
Date: 2020-04-01T19:55:00+02:00
New Revision: 4b35c816ef7afd9e39da621174c1b03b2f325830
URL: https://github.com/llvm/llvm-project/commit/4b35c816ef7afd9e39da621174c1b03b2f325830
DIFF: https://github.com/llvm/llvm-project/commit/4b35c816ef7afd9e39da621174c1b03b2f325830.diff
LOG: [InstCombine] Use replaceOperand() in div transforms
To make sure the old operand is DCEd.
NFC apart from worklist order.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index 899e8b876a48..195916ead66a 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -72,7 +72,7 @@ static Value *simplifyValueKnownNonZero(Value *V, InstCombiner &IC,
// We know that this is an exact/nuw shift and that the input is a
// non-zero context as well.
if (Value *V2 = simplifyValueKnownNonZero(I->getOperand(0), IC, CxtI)) {
- I->setOperand(0, V2);
+ IC.replaceOperand(*I, 0, V2);
MadeChange = true;
}
@@ -591,7 +591,7 @@ bool InstCombiner::simplifyDivRemOfSelectWithZeroOp(BinaryOperator &I) {
return false;
// Change the div/rem to use 'Y' instead of the select.
- I.setOperand(1, SI->getOperand(NonNullOperand));
+ replaceOperand(I, 1, SI->getOperand(NonNullOperand));
// Okay, we know we replace the operand of the div/rem with 'Y' with no
// problem. However, the select, or the condition of the select may have
@@ -619,11 +619,11 @@ bool InstCombiner::simplifyDivRemOfSelectWithZeroOp(BinaryOperator &I) {
for (Instruction::op_iterator I = BBI->op_begin(), E = BBI->op_end();
I != E; ++I) {
if (*I == SI) {
- *I = SI->getOperand(NonNullOperand);
+ replaceUse(*I, SI->getOperand(NonNullOperand));
Worklist.push(&*BBI);
} else if (*I == SelectCond) {
- *I = NonNullOperand == 1 ? ConstantInt::getTrue(CondTy)
- : ConstantInt::getFalse(CondTy);
+ replaceUse(*I, NonNullOperand == 1 ? ConstantInt::getTrue(CondTy)
+ : ConstantInt::getFalse(CondTy));
Worklist.push(&*BBI);
}
}
More information about the llvm-commits
mailing list