Skip to content

Commit 4884adc

Browse files
committed
Address review comments
1 parent d47bfd7 commit 4884adc

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ class LoopVectorizationLegality {
434434

435435
/// Return a vector of all potentially faulting pointers in a loop with
436436
/// uncountable early exits.
437-
const SmallVectorImpl<std::pair<const SCEV *, Type *>> *
437+
ArrayRef<std::pair<const SCEV *, Type *>>
438438
getPotentiallyFaultingPointers() const {
439-
return &PotentiallyFaultingPtrs;
439+
return PotentiallyFaultingPtrs;
440440
}
441441

442442
/// Returns a HistogramInfo* for the given instruction if it was determined
@@ -547,7 +547,7 @@ class LoopVectorizationLegality {
547547
/// Returns true if all loads in the loop contained in \p Loads can be
548548
/// analyzed as potentially faulting. Any loads that may fault are added to
549549
/// the member variable PotentiallyFaultingPtrs.
550-
bool analyzePotentiallyFaultingLoads(SmallVectorImpl<LoadInst *> *Loads);
550+
bool analyzePotentiallyFaultingLoads(SmallVectorImpl<LoadInst *> &Loads);
551551

552552
/// Return true if all of the instructions in the block can be speculatively
553553
/// executed, and record the loads/stores that require masking.

llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,17 +1603,20 @@ bool LoopVectorizationLegality::canVectorizeLoopNestCFG(
16031603
}
16041604

16051605
bool LoopVectorizationLegality::analyzePotentiallyFaultingLoads(
1606-
SmallVectorImpl<LoadInst *> *Loads) {
1606+
SmallVectorImpl<LoadInst *> &Loads) {
16071607
LLVM_DEBUG(dbgs() << "LV: Looking for potentially faulting loads in loop "
16081608
"with uncountable early exit:\n");
1609-
for (LoadInst *LI : *Loads) {
1609+
for (LoadInst *LI : Loads) {
16101610
LLVM_DEBUG(dbgs() << "LV: Load: " << *LI << '\n');
1611-
Value *Ptr = LI->getPointerOperand();
1612-
if (!Ptr)
1611+
if (LI->getPointerAddressSpace())
16131612
return false;
1613+
1614+
Value *Ptr = LI->getPointerOperand();
16141615
const SCEV *PtrExpr = PSE.getSCEV(Ptr);
16151616
const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(PtrExpr);
16161617
// TODO: Deal with loop invariant pointers.
1618+
// NOTE: The reasoning below is only safe if the load executes at least
1619+
// once.
16171620
if (!AR || AR->getLoop() != TheLoop || !AR->isAffine())
16181621
return false;
16191622
auto Step = dyn_cast<SCEVConstant>(AR->getStepRecurrence(*PSE.getSE()));
@@ -1785,7 +1788,7 @@ bool LoopVectorizationLegality::isVectorizableEarlyExitLoop() {
17851788

17861789
if (!NonDerefLoads.empty()) {
17871790
if (!TTI->getMinPageSize() ||
1788-
!analyzePotentiallyFaultingLoads(&NonDerefLoads)) {
1791+
!analyzePotentiallyFaultingLoads(NonDerefLoads)) {
17891792
PotentiallyFaultingPtrs.clear();
17901793
reportVectorizationFailure(
17911794
"Loop may fault",

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,13 +2170,13 @@ class GeneratedRTChecks {
21702170
} // namespace
21712171

21722172
static void addPointerAlignmentChecks(
2173-
const SmallVectorImpl<std::pair<const SCEV *, Type *>> *Ptrs, Function *F,
2173+
ArrayRef<std::pair<const SCEV *, Type *>> Ptrs, Function *F,
21742174
PredicatedScalarEvolution &PSE, TargetTransformInfo *TTI, ElementCount VF,
21752175
unsigned IC) {
21762176
ScalarEvolution *SE = PSE.getSE();
21772177
const DataLayout &DL = SE->getDataLayout();
21782178

2179-
for (auto Ptr : *Ptrs) {
2179+
for (auto Ptr : Ptrs) {
21802180
Type *PtrIntType = DL.getIntPtrType(Ptr.first->getType());
21812181
APInt EltSize(PtrIntType->getScalarSizeInBits(),
21822182
DL.getTypeStoreSize(Ptr.second).getFixedValue());
@@ -2186,7 +2186,7 @@ static void addPointerAlignmentChecks(
21862186
SE->getMulExpr(ScevEC, SE->getConstant(EltSize),
21872187
(SCEV::NoWrapFlags)(SCEV::FlagNSW | SCEV::FlagNUW));
21882188
const SCEV *Rem = SE->getURemExpr(Start, Align);
2189-
PSE.addPredicate(*(SE->getEqualPredicate(Rem, SE->getZero(PtrIntType))));
2189+
PSE.addPredicate(*SE->getEqualPredicate(Rem, SE->getZero(PtrIntType)));
21902190
}
21912191
}
21922192

0 commit comments

Comments
 (0)