@@ -1856,20 +1856,19 @@ bool VectorCombine::scalarizeLoad(Instruction &I) {
18561856
18571857 auto *LI = cast<LoadInst>(&I);
18581858 auto *VecTy = cast<VectorType>(LI->getType ());
1859- if (!VecTy || LI->isVolatile () ||
1860- !DL->typeSizeEqualsStoreSize (VecTy->getScalarType ()))
1859+ if (LI->isVolatile () || !DL->typeSizeEqualsStoreSize (VecTy->getScalarType ()))
18611860 return false ;
18621861
1863- // Check what type of users we have and ensure no memory modifications betwwen
1864- // the load and its users.
18651862 bool AllExtracts = true ;
18661863 bool AllBitcasts = true ;
18671864 Instruction *LastCheckedInst = LI;
18681865 unsigned NumInstChecked = 0 ;
18691866
1867+ // Check what type of users we have and ensure no memory modifications betwwen
1868+ // the load and its users.
18701869 for (User *U : LI->users ()) {
18711870 auto *UI = dyn_cast<Instruction>(U);
1872- if (!UI || UI->getParent () != LI->getParent () || UI-> use_empty () )
1871+ if (!UI || UI->getParent () != LI->getParent ())
18731872 return false ;
18741873
18751874 // If any user is waiting to be erased, then bail out as this will
@@ -1909,18 +1908,18 @@ bool VectorCombine::scalarizeLoadExtract(LoadInst *LI, VectorType *VecTy,
19091908 if (!TTI.allowVectorElementIndexingUsingGEP ())
19101909 return false ;
19111910
1912- InstructionCost OriginalCost =
1913- TTI.getMemoryOpCost (Instruction::Load, VecTy, LI->getAlign (),
1914- LI->getPointerAddressSpace (), CostKind);
1915- InstructionCost ScalarizedCost = 0 ;
1916-
19171911 DenseMap<ExtractElementInst *, ScalarizationResult> NeedFreeze;
19181912 auto FailureGuard = make_scope_exit ([&]() {
19191913 // If the transform is aborted, discard the ScalarizationResults.
19201914 for (auto &Pair : NeedFreeze)
19211915 Pair.second .discard ();
19221916 });
19231917
1918+ InstructionCost OriginalCost =
1919+ TTI.getMemoryOpCost (Instruction::Load, VecTy, LI->getAlign (),
1920+ LI->getPointerAddressSpace (), CostKind);
1921+ InstructionCost ScalarizedCost = 0 ;
1922+
19241923 for (User *U : LI->users ()) {
19251924 auto *UI = cast<ExtractElementInst>(U);
19261925
@@ -2011,7 +2010,7 @@ bool VectorCombine::scalarizeLoadBitcast(LoadInst *LI, VectorType *VecTy,
20112010 if (DestBitWidth != VecBitWidth)
20122011 return false ;
20132012
2014- // All bitcasts should target the same scalar type.
2013+ // All bitcasts must target the same scalar type.
20152014 if (!TargetScalarType)
20162015 TargetScalarType = DestTy;
20172016 else if (TargetScalarType != DestTy)
@@ -2024,6 +2023,7 @@ bool VectorCombine::scalarizeLoadBitcast(LoadInst *LI, VectorType *VecTy,
20242023
20252024 if (!TargetScalarType)
20262025 return false ;
2026+
20272027 assert (!LI->user_empty () && " Unexpected load without bitcast users" );
20282028 InstructionCost ScalarizedCost =
20292029 TTI.getMemoryOpCost (Instruction::Load, TargetScalarType, LI->getAlign (),
0 commit comments