diff --git a/llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp b/llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp --- a/llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp +++ b/llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp @@ -952,25 +952,23 @@ Phi = cast(Offs->getOperand(1)); OffsSecondOp = 0; } else { - bool Changed = true; + bool Changed = false; if (isa(Offs->getOperand(0)) && L->contains(cast(Offs->getOperand(0)))) Changed |= optimiseOffsets(Offs->getOperand(0), BB, LI); if (isa(Offs->getOperand(1)) && L->contains(cast(Offs->getOperand(1)))) Changed |= optimiseOffsets(Offs->getOperand(1), BB, LI); - if (!Changed) { + if (!Changed) return false; + if (isa(Offs->getOperand(0))) { + Phi = cast(Offs->getOperand(0)); + OffsSecondOp = 1; + } else if (isa(Offs->getOperand(1))) { + Phi = cast(Offs->getOperand(1)); + OffsSecondOp = 0; } else { - if (isa(Offs->getOperand(0))) { - Phi = cast(Offs->getOperand(0)); - OffsSecondOp = 1; - } else if (isa(Offs->getOperand(1))) { - Phi = cast(Offs->getOperand(1)); - OffsSecondOp = 0; - } else { - return false; - } + return false; } } // A phi node we want to perform this function on should be from the