Skip to content

Commit d736571

Browse files
author
Anna Welker
committed
[ARM][MVE] Fix ___location of optimized gather addresses
Fix for the address optimization for gathers and scatters which would in some complex cases push out instructions not to the vector loop preheader, but to other locations as well which lead to a scrambled order and the compilation failing. This patch ensures that said instructions are always pushed to the end of the vector loop preheader. Differential Revision: https://reviews.llvm.org/D78293
1 parent a3237f8 commit d736571

File tree

2 files changed

+307
-64
lines changed

2 files changed

+307
-64
lines changed

llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,7 @@ void MVEGatherScatterLowering::pushOutAdd(PHINode *&Phi,
463463
Value *OffsSecondOperand,
464464
unsigned StartIndex) {
465465
LLVM_DEBUG(dbgs() << "masked gathers/scatters: optimising add instruction\n");
466-
Instruction *InsertionPoint;
467-
if (isa<Instruction>(OffsSecondOperand))
468-
InsertionPoint = &cast<Instruction>(OffsSecondOperand)->getParent()->back();
469-
else
470-
InsertionPoint =
466+
Instruction *InsertionPoint =
471467
&cast<Instruction>(Phi->getIncomingBlock(StartIndex)->back());
472468
// Initialize the phi with a vector that contains a sum of the constants
473469
Instruction *NewIndex = BinaryOperator::Create(
@@ -492,11 +488,7 @@ void MVEGatherScatterLowering::pushOutMul(PHINode *&Phi,
492488

493489
// Create a new scalar add outside of the loop and transform it to a splat
494490
// by which loop variable can be incremented
495-
Instruction *InsertionPoint;
496-
if (isa<Instruction>(OffsSecondOperand))
497-
InsertionPoint = &cast<Instruction>(OffsSecondOperand)->getParent()->back();
498-
else
499-
InsertionPoint = &cast<Instruction>(
491+
Instruction *InsertionPoint = &cast<Instruction>(
500492
Phi->getIncomingBlock(LoopIncrement == 1 ? 0 : 1)->back());
501493

502494
// Create a new index

0 commit comments

Comments
 (0)