Index: llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp =================================================================== --- llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp +++ llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp @@ -990,26 +990,27 @@ SmallVector Gathers; SmallVector Scatters; + bool Changed = false; + for (BasicBlock &BB : F) { for (Instruction &I : BB) { IntrinsicInst *II = dyn_cast(&I); if (II && II->getIntrinsicID() == Intrinsic::masked_gather) { Gathers.push_back(II); if (isa(II->getArgOperand(0))) - optimiseOffsets( + Changed |= optimiseOffsets( cast(II->getArgOperand(0))->getOperand(1), II->getParent(), LI); } else if (II && II->getIntrinsicID() == Intrinsic::masked_scatter) { Scatters.push_back(II); if (isa(II->getArgOperand(1))) - optimiseOffsets( + Changed |= optimiseOffsets( cast(II->getArgOperand(1))->getOperand(1), II->getParent(), LI); } } } - bool Changed = false; for (unsigned i = 0; i < Gathers.size(); i++) { IntrinsicInst *I = Gathers[i]; Value *L = lowerGather(I);