@@ -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