[llvm] 0f1f921 - [ARM] Fix incorrect assignment of Changed variable in MVEGatherScatterLowering::optimiseOffsets.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 30 07:53:04 PDT 2021
Author: Craig Topper
Date: 2021-06-30T07:52:57-07:00
New Revision: 0f1f92156f3caafe9567b853ecb57212b709e68d
URL: https://github.com/llvm/llvm-project/commit/0f1f92156f3caafe9567b853ecb57212b709e68d
DIFF: https://github.com/llvm/llvm-project/commit/0f1f92156f3caafe9567b853ecb57212b709e68d.diff
LOG: [ARM] Fix incorrect assignment of Changed variable in MVEGatherScatterLowering::optimiseOffsets.
I believe this Changed flag should be initialized to false,
otherwise the if (!Changed) is always dead. This doesn't
manifest in a functional issue because the PHINode checks will
fail if nothing changed. They are identical to the earlier
checks that must have already failed to get into this else block.
While there remove an else after return to reduce indentation.
Differential Revision: https://reviews.llvm.org/D105159
Added:
Modified:
llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp b/llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp
index 74e0fb4ac575..339ca18179b3 100644
--- a/llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp
+++ b/llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp
@@ -952,25 +952,23 @@ bool MVEGatherScatterLowering::optimiseOffsets(Value *Offsets, BasicBlock *BB,
Phi = cast<PHINode>(Offs->getOperand(1));
OffsSecondOp = 0;
} else {
- bool Changed = true;
+ bool Changed = false;
if (isa<Instruction>(Offs->getOperand(0)) &&
L->contains(cast<Instruction>(Offs->getOperand(0))))
Changed |= optimiseOffsets(Offs->getOperand(0), BB, LI);
if (isa<Instruction>(Offs->getOperand(1)) &&
L->contains(cast<Instruction>(Offs->getOperand(1))))
Changed |= optimiseOffsets(Offs->getOperand(1), BB, LI);
- if (!Changed) {
+ if (!Changed)
return false;
+ if (isa<PHINode>(Offs->getOperand(0))) {
+ Phi = cast<PHINode>(Offs->getOperand(0));
+ OffsSecondOp = 1;
+ } else if (isa<PHINode>(Offs->getOperand(1))) {
+ Phi = cast<PHINode>(Offs->getOperand(1));
+ OffsSecondOp = 0;
} else {
- if (isa<PHINode>(Offs->getOperand(0))) {
- Phi = cast<PHINode>(Offs->getOperand(0));
- OffsSecondOp = 1;
- } else if (isa<PHINode>(Offs->getOperand(1))) {
- Phi = cast<PHINode>(Offs->getOperand(1));
- OffsSecondOp = 0;
- } else {
- return false;
- }
+ return false;
}
}
// A phi node we want to perform this function on should be from the
More information about the llvm-commits
mailing list