Skip to content

Commit b195bb8

Browse files
committed
[VectorCombine] scalarizeLoadExtract - consistently use LoadInst and ExtractElementInst specific operand getters. NFC
Noticed while investigating the hung builds reported after af83093
1 parent 6279d2e commit b195bb8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,8 +1360,8 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
13601360
if (!match(&I, m_Load(m_Value(Ptr))))
13611361
return false;
13621362

1363-
auto *VecTy = cast<VectorType>(I.getType());
13641363
auto *LI = cast<LoadInst>(&I);
1364+
auto *VecTy = cast<VectorType>(LI->getType());
13651365
if (LI->isVolatile() || !DL->typeSizeEqualsStoreSize(VecTy->getScalarType()))
13661366
return false;
13671367

@@ -1401,15 +1401,16 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
14011401
LastCheckedInst = UI;
14021402
}
14031403

1404-
auto ScalarIdx = canScalarizeAccess(VecTy, UI->getOperand(1), &I, AC, DT);
1404+
auto ScalarIdx =
1405+
canScalarizeAccess(VecTy, UI->getIndexOperand(), LI, AC, DT);
14051406
if (ScalarIdx.isUnsafe())
14061407
return false;
14071408
if (ScalarIdx.isSafeWithFreeze()) {
14081409
NeedFreeze.try_emplace(UI, ScalarIdx);
14091410
ScalarIdx.discard();
14101411
}
14111412

1412-
auto *Index = dyn_cast<ConstantInt>(UI->getOperand(1));
1413+
auto *Index = dyn_cast<ConstantInt>(UI->getIndexOperand());
14131414
OriginalCost +=
14141415
TTI.getVectorInstrCost(Instruction::ExtractElement, VecTy, CostKind,
14151416
Index ? Index->getZExtValue() : -1);
@@ -1425,7 +1426,7 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
14251426
// Replace extracts with narrow scalar loads.
14261427
for (User *U : LI->users()) {
14271428
auto *EI = cast<ExtractElementInst>(U);
1428-
Value *Idx = EI->getOperand(1);
1429+
Value *Idx = EI->getIndexOperand();
14291430

14301431
// Insert 'freeze' for poison indexes.
14311432
auto It = NeedFreeze.find(EI);

0 commit comments

Comments
 (0)