@@ -1856,20 +1856,20 @@ 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 (must either all be extracts or
1868+ // bitcasts) and ensure no memory modifications between the load and
1869+ // its users.
18701870 for (User *U : LI->users ()) {
18711871 auto *UI = dyn_cast<Instruction>(U);
1872- if (!UI || UI->getParent () != LI->getParent () || UI-> use_empty () )
1872+ if (!UI || UI->getParent () != LI->getParent ())
18731873 return false ;
18741874
18751875 // If any user is waiting to be erased, then bail out as this will
@@ -1909,18 +1909,18 @@ bool VectorCombine::scalarizeLoadExtract(LoadInst *LI, VectorType *VecTy,
19091909 if (!TTI.allowVectorElementIndexingUsingGEP ())
19101910 return false ;
19111911
1912- InstructionCost OriginalCost =
1913- TTI.getMemoryOpCost (Instruction::Load, VecTy, LI->getAlign (),
1914- LI->getPointerAddressSpace (), CostKind);
1915- InstructionCost ScalarizedCost = 0 ;
1916-
19171912 DenseMap<ExtractElementInst *, ScalarizationResult> NeedFreeze;
19181913 auto FailureGuard = make_scope_exit ([&]() {
19191914 // If the transform is aborted, discard the ScalarizationResults.
19201915 for (auto &Pair : NeedFreeze)
19211916 Pair.second .discard ();
19221917 });
19231918
1919+ InstructionCost OriginalCost =
1920+ TTI.getMemoryOpCost (Instruction::Load, VecTy, LI->getAlign (),
1921+ LI->getPointerAddressSpace (), CostKind);
1922+ InstructionCost ScalarizedCost = 0 ;
1923+
19241924 for (User *U : LI->users ()) {
19251925 auto *UI = cast<ExtractElementInst>(U);
19261926
@@ -2011,7 +2011,7 @@ bool VectorCombine::scalarizeLoadBitcast(LoadInst *LI, VectorType *VecTy,
20112011 if (DestBitWidth != VecBitWidth)
20122012 return false ;
20132013
2014- // All bitcasts should target the same scalar type.
2014+ // All bitcasts must target the same scalar type.
20152015 if (!TargetScalarType)
20162016 TargetScalarType = DestTy;
20172017 else if (TargetScalarType != DestTy)
@@ -2024,6 +2024,7 @@ bool VectorCombine::scalarizeLoadBitcast(LoadInst *LI, VectorType *VecTy,
20242024
20252025 if (!TargetScalarType)
20262026 return false ;
2027+
20272028 assert (!LI->user_empty () && " Unexpected load without bitcast users" );
20282029 InstructionCost ScalarizedCost =
20292030 TTI.getMemoryOpCost (Instruction::Load, TargetScalarType, LI->getAlign (),
0 commit comments