@@ -1360,8 +1360,8 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
1360
1360
if (!match (&I, m_Load (m_Value (Ptr ))))
1361
1361
return false ;
1362
1362
1363
- auto *VecTy = cast<VectorType>(I.getType ());
1364
1363
auto *LI = cast<LoadInst>(&I);
1364
+ auto *VecTy = cast<VectorType>(LI->getType ());
1365
1365
if (LI->isVolatile () || !DL->typeSizeEqualsStoreSize (VecTy->getScalarType ()))
1366
1366
return false ;
1367
1367
@@ -1401,15 +1401,16 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
1401
1401
LastCheckedInst = UI;
1402
1402
}
1403
1403
1404
- auto ScalarIdx = canScalarizeAccess (VecTy, UI->getOperand (1 ), &I, AC, DT);
1404
+ auto ScalarIdx =
1405
+ canScalarizeAccess (VecTy, UI->getIndexOperand (), LI, AC, DT);
1405
1406
if (ScalarIdx.isUnsafe ())
1406
1407
return false ;
1407
1408
if (ScalarIdx.isSafeWithFreeze ()) {
1408
1409
NeedFreeze.try_emplace (UI, ScalarIdx);
1409
1410
ScalarIdx.discard ();
1410
1411
}
1411
1412
1412
- auto *Index = dyn_cast<ConstantInt>(UI->getOperand ( 1 ));
1413
+ auto *Index = dyn_cast<ConstantInt>(UI->getIndexOperand ( ));
1413
1414
OriginalCost +=
1414
1415
TTI.getVectorInstrCost (Instruction::ExtractElement, VecTy, CostKind,
1415
1416
Index ? Index->getZExtValue () : -1 );
@@ -1425,7 +1426,7 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
1425
1426
// Replace extracts with narrow scalar loads.
1426
1427
for (User *U : LI->users ()) {
1427
1428
auto *EI = cast<ExtractElementInst>(U);
1428
- Value *Idx = EI->getOperand ( 1 );
1429
+ Value *Idx = EI->getIndexOperand ( );
1429
1430
1430
1431
// Insert 'freeze' for poison indexes.
1431
1432
auto It = NeedFreeze.find (EI);
0 commit comments