Skip to content

Commit 3b1e184

Browse files
committed
Reuse InBounds
1 parent 38e145c commit 3b1e184

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2482,23 +2482,23 @@ void VPlanTransforms::createInterleaveGroups(
24822482
auto *InsertPos =
24832483
cast<VPWidenMemoryRecipe>(RecipeBuilder.getRecipe(IRInsertPos));
24842484

2485+
bool InBounds = false;
2486+
if (auto *Gep = dyn_cast<GetElementPtrInst>(
2487+
getLoadStorePointerOperand(IRInsertPos)->stripPointerCasts()))
2488+
InBounds = Gep->isInBounds();
2489+
24852490
// Get or create the start address for the interleave group.
24862491
auto *Start =
24872492
cast<VPWidenMemoryRecipe>(RecipeBuilder.getRecipe(IG->getMember(0)));
24882493
VPValue *Addr = Start->getAddr();
24892494
VPRecipeBase *AddrDef = Addr->getDefiningRecipe();
24902495
if (AddrDef && !VPDT.properlyDominates(AddrDef, InsertPos)) {
2491-
// TODO: Hoist Addr's defining recipe (and any operands as needed) to
2492-
// InsertPos or sink loads above zero members to join it.
2493-
bool InBounds = false;
2494-
if (auto *Gep = dyn_cast<GetElementPtrInst>(
2495-
getLoadStorePointerOperand(IRInsertPos)->stripPointerCasts()))
2496-
InBounds = Gep->isInBounds();
2497-
24982496
// We cannot re-use the address of member zero because it does not
24992497
// dominate the insert position. Instead, use the address of the insert
25002498
// position and create a PtrAdd adjusting it to the address of member
25012499
// zero.
2500+
// TODO: Hoist Addr's defining recipe (and any operands as needed) to
2501+
// InsertPos or sink loads above zero members to join it.
25022502
assert(IG->getIndex(IRInsertPos) != 0 &&
25032503
"index of insert position shouldn't be zero");
25042504
auto &DL = IRInsertPos->getDataLayout();
@@ -2522,8 +2522,7 @@ void VPlanTransforms::createInterleaveGroups(
25222522
auto *ReversePtr = new VPVectorEndPointerRecipe(
25232523
Addr, &Plan.getVF(), getLoadStoreType(IRInsertPos),
25242524
-(int64_t)IG->getFactor(),
2525-
GEP && GEP->isInBounds() ? GEPNoWrapFlags::inBounds()
2526-
: GEPNoWrapFlags::none(),
2525+
InBounds ? GEPNoWrapFlags::inBounds() : GEPNoWrapFlags::none(),
25272526
InsertPos->getDebugLoc());
25282527
ReversePtr->insertBefore(InsertPos);
25292528
Addr = ReversePtr;

0 commit comments

Comments
 (0)