@@ -278,13 +278,14 @@ void BottomUpVec::collectPotentiallyDeadInstrs(ArrayRef<Value *> Bndl) {
278
278
}
279
279
280
280
Action *BottomUpVec::vectorizeRec (ArrayRef<Value *> Bndl,
281
- ArrayRef<Value *> UserBndl, unsigned Depth) {
281
+ ArrayRef<Value *> UserBndl, unsigned Depth,
282
+ LegalityAnalysis &Legality) {
282
283
bool StopForDebug =
283
284
DebugBndlCnt++ >= StopBundle && StopBundle != StopBundleDisabled;
284
285
LLVM_DEBUG (dbgs () << DEBUG_PREFIX << " canVectorize() Bundle:\n " ;
285
286
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);
288
289
LLVM_DEBUG (dbgs () << DEBUG_PREFIX << " Legality: " << LegalityRes << " \n " );
289
290
auto ActionPtr =
290
291
std::make_unique<Action>(&LegalityRes, Bndl, UserBndl, Depth);
@@ -297,14 +298,16 @@ Action *BottomUpVec::vectorizeRec(ArrayRef<Value *> Bndl,
297
298
break ;
298
299
case Instruction::Opcode::Store: {
299
300
// 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);
301
303
Operands.push_back (OpA);
302
304
break ;
303
305
}
304
306
default :
305
307
// Visit all operands.
306
308
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);
308
311
Operands.push_back (OpA);
309
312
}
310
313
break ;
@@ -476,16 +479,17 @@ Value *BottomUpVec::emitVectors() {
476
479
return NewVec;
477
480
}
478
481
479
- bool BottomUpVec::tryVectorize (ArrayRef<Value *> Bndl) {
482
+ bool BottomUpVec::tryVectorize (ArrayRef<Value *> Bndl,
483
+ LegalityAnalysis &Legality) {
480
484
Change = false ;
481
485
if (LLVM_UNLIKELY (BottomUpInvocationCnt++ >= StopAt &&
482
486
StopAt != StopAtDisabled))
483
487
return false ;
484
488
DeadInstrCandidates.clear ();
485
- Legality-> clear ();
489
+ Legality. clear ();
486
490
Actions.clear ();
487
491
DebugBndlCnt = 0 ;
488
- vectorizeRec (Bndl, {}, /* Depth=*/ 0 );
492
+ vectorizeRec (Bndl, {}, /* Depth=*/ 0 , Legality );
489
493
LLVM_DEBUG (dbgs () << DEBUG_PREFIX << " BottomUpVec: Vectorization Actions:\n " ;
490
494
Actions.dump ());
491
495
emitVectors ();
@@ -498,16 +502,16 @@ bool BottomUpVec::runOnRegion(Region &Rgn, const Analyses &A) {
498
502
assert (SeedSlice.size () >= 2 && " Bad slice!" );
499
503
Function &F = *SeedSlice[0 ]->getParent ()->getParent ();
500
504
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);
504
508
505
509
// TODO: Refactor to remove the unnecessary copy to SeedSliceVals.
506
510
SmallVector<Value *> SeedSliceVals (SeedSlice.begin (), SeedSlice.end ());
507
511
// Try to vectorize starting from the seed slice. The returned value
508
512
// is true if we found vectorizable code and generated some vector
509
513
// code for it. It does not mean that the code is profitable.
510
- return tryVectorize (SeedSliceVals);
514
+ return tryVectorize (SeedSliceVals, Legality );
511
515
}
512
516
513
517
} // namespace sandboxir
0 commit comments