@@ -278,13 +278,14 @@ void BottomUpVec::collectPotentiallyDeadInstrs(ArrayRef<Value *> Bndl) {
278278}
279279
280280Action *BottomUpVec::vectorizeRec (ArrayRef<Value *> Bndl,
281- ArrayRef<Value *> UserBndl, unsigned Depth) {
281+ ArrayRef<Value *> UserBndl, unsigned Depth,
282+ LegalityAnalysis &Legality) {
282283 bool StopForDebug =
283284 DebugBndlCnt++ >= StopBundle && StopBundle != StopBundleDisabled;
284285 LLVM_DEBUG (dbgs () << DEBUG_PREFIX << " canVectorize() Bundle:\n " ;
285286 VecUtils::dump (Bndl));
286- const auto &LegalityRes = StopForDebug ? Legality-> getForcedPackForDebugging ()
287- : Legality-> canVectorize (Bndl);
287+ const auto &LegalityRes = StopForDebug ? Legality. getForcedPackForDebugging ()
288+ : Legality. canVectorize (Bndl);
288289 LLVM_DEBUG (dbgs () << DEBUG_PREFIX << " Legality: " << LegalityRes << " \n " );
289290 auto ActionPtr =
290291 std::make_unique<Action>(&LegalityRes, Bndl, UserBndl, Depth);
@@ -297,14 +298,16 @@ Action *BottomUpVec::vectorizeRec(ArrayRef<Value *> Bndl,
297298 break ;
298299 case Instruction::Opcode::Store: {
299300 // Don't recurse towards the pointer operand.
300- Action *OpA = vectorizeRec (getOperand (Bndl, 0 ), Bndl, Depth + 1 );
301+ Action *OpA =
302+ vectorizeRec (getOperand (Bndl, 0 ), Bndl, Depth + 1 , Legality);
301303 Operands.push_back (OpA);
302304 break ;
303305 }
304306 default :
305307 // Visit all operands.
306308 for (auto OpIdx : seq<unsigned >(I->getNumOperands ())) {
307- Action *OpA = vectorizeRec (getOperand (Bndl, OpIdx), Bndl, Depth + 1 );
309+ Action *OpA =
310+ vectorizeRec (getOperand (Bndl, OpIdx), Bndl, Depth + 1 , Legality);
308311 Operands.push_back (OpA);
309312 }
310313 break ;
@@ -476,16 +479,17 @@ Value *BottomUpVec::emitVectors() {
476479 return NewVec;
477480}
478481
479- bool BottomUpVec::tryVectorize (ArrayRef<Value *> Bndl) {
482+ bool BottomUpVec::tryVectorize (ArrayRef<Value *> Bndl,
483+ LegalityAnalysis &Legality) {
480484 Change = false ;
481485 if (LLVM_UNLIKELY (BottomUpInvocationCnt++ >= StopAt &&
482486 StopAt != StopAtDisabled))
483487 return false ;
484488 DeadInstrCandidates.clear ();
485- Legality-> clear ();
489+ Legality. clear ();
486490 Actions.clear ();
487491 DebugBndlCnt = 0 ;
488- vectorizeRec (Bndl, {}, /* Depth=*/ 0 );
492+ vectorizeRec (Bndl, {}, /* Depth=*/ 0 , Legality );
489493 LLVM_DEBUG (dbgs () << DEBUG_PREFIX << " BottomUpVec: Vectorization Actions:\n " ;
490494 Actions.dump ());
491495 emitVectors ();
@@ -498,16 +502,16 @@ bool BottomUpVec::runOnRegion(Region &Rgn, const Analyses &A) {
498502 assert (SeedSlice.size () >= 2 && " Bad slice!" );
499503 Function &F = *SeedSlice[0 ]->getParent ()->getParent ();
500504 IMaps = std::make_unique<InstrMaps>();
501- Legality = std::make_unique<LegalityAnalysis>(
502- A. getAA (), A. getScalarEvolution (), F.getParent ()->getDataLayout (),
503- F. getContext (), *IMaps);
505+ LegalityAnalysis Legality (A. getAA (), A. getScalarEvolution (),
506+ F.getParent ()->getDataLayout (), F. getContext (),
507+ *IMaps);
504508
505509 // TODO: Refactor to remove the unnecessary copy to SeedSliceVals.
506510 SmallVector<Value *> SeedSliceVals (SeedSlice.begin (), SeedSlice.end ());
507511 // Try to vectorize starting from the seed slice. The returned value
508512 // is true if we found vectorizable code and generated some vector
509513 // code for it. It does not mean that the code is profitable.
510- return tryVectorize (SeedSliceVals);
514+ return tryVectorize (SeedSliceVals, Legality );
511515}
512516
513517} // namespace sandboxir
0 commit comments