Skip to content

Commit 5ba1150

Browse files
committed
[PSE] Remove assumption that top level predicate is union from public interface [NFC*]
Note that this doesn't actually cause the top level predicate to become a non-union just yet. The * above comes from a case in the LoopVectorizer where a predicate which is later proven no longer blocks vectorization due to a change from checking if predicates exists to whether the predicate is possibly false.
1 parent ecbcefd commit 5ba1150

File tree

9 files changed

+18
-18
lines changed

9 files changed

+18
-18
lines changed

llvm/include/llvm/Analysis/ScalarEvolution.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2199,7 +2199,7 @@ class PredicatedScalarEvolution {
21992199
public:
22002200
PredicatedScalarEvolution(ScalarEvolution &SE, Loop &L);
22012201

2202-
const SCEVUnionPredicate &getUnionPredicate() const;
2202+
const SCEVPredicate &getPredicate() const;
22032203

22042204
/// Returns the SCEV expression of V, in the context of the current SCEV
22052205
/// predicate. The order of transformations applied on the expression of V

llvm/include/llvm/Transforms/Utils/LoopVersioning.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class LoopVersioning {
123123
SmallVector<RuntimePointerCheck, 4> AliasChecks;
124124

125125
/// The set of SCEV checks that we are versioning for.
126-
const SCEVUnionPredicate &Preds;
126+
const SCEVPredicate &Preds;
127127

128128
/// Maps a pointer to the pointer checking group that the pointer
129129
/// belongs to.

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2342,7 +2342,7 @@ void LoopAccessInfo::print(raw_ostream &OS, unsigned Depth) const {
23422342
<< "found in loop.\n";
23432343

23442344
OS.indent(Depth) << "SCEV assumptions:\n";
2345-
PSE->getUnionPredicate().print(OS, Depth);
2345+
PSE->getPredicate().print(OS, Depth);
23462346

23472347
OS << "\n";
23482348

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13975,7 +13975,7 @@ void PredicatedScalarEvolution::addPredicate(const SCEVPredicate &Pred) {
1397513975
updateGeneration();
1397613976
}
1397713977

13978-
const SCEVUnionPredicate &PredicatedScalarEvolution::getUnionPredicate() const {
13978+
const SCEVPredicate &PredicatedScalarEvolution::getPredicate() const {
1397913979
return *Preds;
1398013980
}
1398113981

llvm/lib/Transforms/Scalar/LoopDistribute.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ class LoopDistributeForLoop {
770770

771771
// Don't distribute the loop if we need too many SCEV run-time checks, or
772772
// any if it's illegal.
773-
const SCEVUnionPredicate &Pred = LAI->getPSE().getUnionPredicate();
773+
const SCEVPredicate &Pred = LAI->getPSE().getPredicate();
774774
if (LAI->hasConvergentOp() && !Pred.isAlwaysTrue()) {
775775
return fail("RuntimeCheckWithConvergent",
776776
"may not insert runtime check with convergent operation");

llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ class LoadEliminationForLoop {
529529
return false;
530530
}
531531

532-
if (LAI.getPSE().getUnionPredicate().getComplexity() >
532+
if (LAI.getPSE().getPredicate().getComplexity() >
533533
LoadElimSCEVCheckThreshold) {
534534
LLVM_DEBUG(dbgs() << "Too many SCEV run-time checks needed.\n");
535535
return false;
@@ -540,7 +540,7 @@ class LoadEliminationForLoop {
540540
return false;
541541
}
542542

543-
if (!Checks.empty() || !LAI.getPSE().getUnionPredicate().isAlwaysTrue()) {
543+
if (!Checks.empty() || !LAI.getPSE().getPredicate().isAlwaysTrue()) {
544544
if (LAI.hasConvergentOp()) {
545545
LLVM_DEBUG(dbgs() << "Versioning is needed but not allowed with "
546546
"convergent calls\n");

llvm/lib/Transforms/Utils/LoopVersioning.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ LoopVersioning::LoopVersioning(const LoopAccessInfo &LAI,
4242
LoopInfo *LI, DominatorTree *DT,
4343
ScalarEvolution *SE)
4444
: VersionedLoop(L), AliasChecks(Checks.begin(), Checks.end()),
45-
Preds(LAI.getPSE().getUnionPredicate()), LAI(LAI), LI(LI), DT(DT),
45+
Preds(LAI.getPSE().getPredicate()), LAI(LAI), LI(LI), DT(DT),
4646
SE(SE) {
4747
}
4848

@@ -276,7 +276,7 @@ bool runImpl(LoopInfo *LI, function_ref<const LoopAccessInfo &(Loop &)> GetLAA,
276276
const LoopAccessInfo &LAI = GetLAA(*L);
277277
if (!LAI.hasConvergentOp() &&
278278
(LAI.getNumRuntimePointerChecks() ||
279-
!LAI.getPSE().getUnionPredicate().isAlwaysTrue())) {
279+
!LAI.getPSE().getPredicate().isAlwaysTrue())) {
280280
LoopVersioning LVer(LAI, LAI.getRuntimePointerChecking()->getChecks(), L,
281281
LI, DT, SE);
282282
LVer.versionLoop();

llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ void LoopVectorizationLegality::addInductionPhi(
572572
// on predicates that only hold within the loop, since allowing the exit
573573
// currently means re-using this SCEV outside the loop (see PR33706 for more
574574
// details).
575-
if (PSE.getUnionPredicate().isAlwaysTrue()) {
575+
if (PSE.getPredicate().isAlwaysTrue()) {
576576
AllowedExit.insert(Phi);
577577
AllowedExit.insert(Phi->getIncomingValueForBlock(TheLoop->getLoopLatch()));
578578
}
@@ -849,7 +849,7 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
849849
// used outside the loop only if the SCEV predicates within the loop is
850850
// same as outside the loop. Allowing the exit means reusing the SCEV
851851
// outside the loop.
852-
if (PSE.getUnionPredicate().isAlwaysTrue()) {
852+
if (PSE.getPredicate().isAlwaysTrue()) {
853853
AllowedExit.insert(&I);
854854
continue;
855855
}
@@ -919,7 +919,7 @@ bool LoopVectorizationLegality::canVectorizeMemory() {
919919
}
920920

921921
Requirements->addRuntimePointerChecks(LAI->getNumRuntimePointerChecks());
922-
PSE.addPredicate(LAI->getPSE().getUnionPredicate());
922+
PSE.addPredicate(LAI->getPSE().getPredicate());
923923
return true;
924924
}
925925

@@ -1266,7 +1266,7 @@ bool LoopVectorizationLegality::canVectorize(bool UseVPlanNativePath) {
12661266
if (Hints->getForce() == LoopVectorizeHints::FK_Enabled)
12671267
SCEVThreshold = PragmaVectorizeSCEVCheckThreshold;
12681268

1269-
if (PSE.getUnionPredicate().getComplexity() > SCEVThreshold) {
1269+
if (PSE.getPredicate().getComplexity() > SCEVThreshold) {
12701270
reportVectorizationFailure("Too many SCEV checks needed",
12711271
"Too many SCEV assumptions need to be made and checked at runtime",
12721272
"TooManySCEVRunTimeChecks", ORE, TheLoop);

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ class GeneratedRTChecks {
19981998
/// there is no vector code generation, the check blocks are removed
19991999
/// completely.
20002000
void Create(Loop *L, const LoopAccessInfo &LAI,
2001-
const SCEVUnionPredicate &UnionPred) {
2001+
const SCEVPredicate &Pred) {
20022002

20032003
BasicBlock *LoopHeader = L->getHeader();
20042004
BasicBlock *Preheader = L->getLoopPreheader();
@@ -2007,12 +2007,12 @@ class GeneratedRTChecks {
20072007
// ensure the blocks are properly added to LoopInfo & DominatorTree. Those
20082008
// may be used by SCEVExpander. The blocks will be un-linked from their
20092009
// predecessors and removed from LI & DT at the end of the function.
2010-
if (!UnionPred.isAlwaysTrue()) {
2010+
if (!Pred.isAlwaysTrue()) {
20112011
SCEVCheckBlock = SplitBlock(Preheader, Preheader->getTerminator(), DT, LI,
20122012
nullptr, "vector.scevcheck");
20132013

20142014
SCEVCheckCond = SCEVExp.expandCodeForPredicate(
2015-
&UnionPred, SCEVCheckBlock->getTerminator());
2015+
&Pred, SCEVCheckBlock->getTerminator());
20162016
}
20172017

20182018
const auto &RtPtrChecking = *LAI.getRuntimePointerChecking();
@@ -5161,7 +5161,7 @@ bool LoopVectorizationCostModel::runtimeChecksRequired() {
51615161
return true;
51625162
}
51635163

5164-
if (!PSE.getUnionPredicate().getPredicates().empty()) {
5164+
if (!PSE.getPredicate().isAlwaysTrue()) {
51655165
reportVectorizationFailure("Runtime SCEV check is required with -Os/-Oz",
51665166
"runtime SCEV checks needed. Enable vectorization of this "
51675167
"loop with '#pragma clang loop vectorize(enable)' when "
@@ -10557,7 +10557,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1055710557
GeneratedRTChecks Checks(*PSE.getSE(), DT, LI,
1055810558
F->getParent()->getDataLayout());
1055910559
if (!VF.Width.isScalar() || IC > 1)
10560-
Checks.Create(L, *LVL.getLAI(), PSE.getUnionPredicate());
10560+
Checks.Create(L, *LVL.getLAI(), PSE.getPredicate());
1056110561

1056210562
using namespace ore;
1056310563
if (!VectorizeLoop) {

0 commit comments

Comments
 (0)