Skip to content

Commit 8e400b9

Browse files
committed
[AMDGPU] Update.
1 parent f2efffb commit 8e400b9

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -456,32 +456,19 @@ static Value *GEPToVectorIndex(GetElementPtrInst *GEP, AllocaInst *Alloca,
456456
// That lets us emit a single buffer_load directly into a VGPR, without ever
457457
// allocating scratch memory for the intermediate pointer.
458458
Value *CurPtr = GEP;
459-
SmallMapVector<Value *, APInt, 4> LocalVarsOffsets;
460459
while (auto *CurGEP = dyn_cast<GetElementPtrInst>(CurPtr)) {
461-
if (!CurGEP->collectOffset(DL, BW, LocalVarsOffsets, ConstOffset))
460+
if (!CurGEP->collectOffset(DL, BW, VarOffsets, ConstOffset))
462461
return nullptr;
463462

464-
// Merge index contributions from this GEP into VarOffsets.
465-
// Only one dynamic index is allowed in the entire GEP chain.
466-
// Abort if a different index variable is encountered.
467-
for (auto &[Var, Offset] : LocalVarsOffsets) {
468-
// If VarOffsets already records a different variable index, abort.
469-
if (!VarOffsets.empty() && !VarOffsets.contains(Var))
470-
return nullptr;
471-
472-
// Try to insert VarEntry.first with its offset; if that pointer is
473-
// already in VarOffsets, add the new offset to the existing one.
474-
auto [Existing, Inserted] = VarOffsets.try_emplace(Var, Offset);
475-
if (!Inserted)
476-
Existing->second += Offset;
477-
}
478-
479-
LocalVarsOffsets.clear();
480-
// Move to the next outer pointer
463+
// Move to the next outer pointer.
481464
CurPtr = CurGEP->getPointerOperand();
482465
}
483466

484-
// Only proceed if this GEP stems from the same alloca.
467+
// Only one dynamic index is allowed in the entire GEP chain.
468+
// Abort if a different index variable is encountered.
469+
if (VarOffsets.size() > 1)
470+
return nullptr;
471+
485472
assert(CurPtr == Alloca && "GEP not based on alloca");
486473

487474
unsigned VecElemSize = DL.getTypeAllocSize(VecElemTy);

0 commit comments

Comments
 (0)