@@ -166,11 +166,12 @@ class SinkStoreInfo {
166166 if (!match (SE.getMinusSCEV (SCEVA, SCEVB), m_scev_APInt (Distance)))
167167 return false ;
168168
169- const DataLayout &DL = L. getHeader ()-> getModule ()-> getDataLayout ();
169+ const DataLayout &DL = SE. getDataLayout ();
170170 Type *TyA = TypeInfo.inferScalarType (A->getOperand (0 ));
171171 uint64_t SizeA = DL.getTypeStoreSize (TyA);
172172 Type *TyB = TypeInfo.inferScalarType (B->getOperand (0 ));
173173 uint64_t SizeB = DL.getTypeStoreSize (TyB);
174+
174175 // Use the maximum store size to ensure no overlap from either direction.
175176 // Currently only handles fixed sizes, as it is only used for
176177 // replicating VPReplicateRecipes.
@@ -193,11 +194,8 @@ class SinkStoreInfo {
193194 // / because it's in the exclude set or because no-alias can be proven via
194195 // / SCEV.
195196 bool shouldSkip (VPRecipeBase &R) const {
196- if (ExcludeRecipes.contains (&R))
197- return true ;
198- if (auto *Store = dyn_cast<VPReplicateRecipe>(&R))
199- return isNoAliasViaDistance (Store, &GroupLeader);
200- return false ;
197+ auto *Store = dyn_cast<VPReplicateRecipe>(&R);
198+ return ExcludeRecipes.contains (&R) || (Store && isNoAliasViaDistance (Store, &GroupLeader));
201199 }
202200};
203201
@@ -209,7 +207,7 @@ class SinkStoreInfo {
209207// / leader and other replicate recipes (for store sinking).
210208static bool canHoistOrSinkWithNoAliasCheck (
211209 const MemoryLocation &MemLoc, VPBasicBlock *FirstBB, VPBasicBlock *LastBB,
212- std::optional<SinkStoreInfo> SinkInfo = std:: nullopt ) {
210+ std::optional<SinkStoreInfo> SinkInfo = {} ) {
213211 bool CheckReads = SinkInfo.has_value ();
214212 if (!MemLoc.AATags .Scope )
215213 return false ;
@@ -4378,8 +4376,8 @@ canSinkStoreWithNoAliasCheck(ArrayRef<VPReplicateRecipe *> StoresToSink,
43784376
43794377 VPBasicBlock *FirstBB = StoresToSink.front ()->getParent ();
43804378 VPBasicBlock *LastBB = StoresToSink.back ()->getParent ();
4381- SinkStoreInfo Info (StoresToSinkSet, *StoresToSink[0 ], SE, L, TypeInfo);
4382- return canHoistOrSinkWithNoAliasCheck (*StoreLoc, FirstBB, LastBB, Info );
4379+ SinkStoreInfo SinkInfo (StoresToSinkSet, *StoresToSink[0 ], SE, L, TypeInfo);
4380+ return canHoistOrSinkWithNoAliasCheck (*StoreLoc, FirstBB, LastBB, SinkInfo );
43834381}
43844382
43854383void VPlanTransforms::sinkPredicatedStores (VPlan &Plan, ScalarEvolution &SE,
0 commit comments