Skip to content

Commit 0a6009d

Browse files
committed
!fixup Update to support pattern matching
1 parent e8ad37f commit 0a6009d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_ANALYSIS_SCALAREVOLUTIONPATTERNMATCH_H
1414
#define LLVM_ANALYSIS_SCALAREVOLUTIONPATTERNMATCH_H
1515

16+
#include "llvm/Analysis/ScalarEvolution.h"
1617
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
1718

1819
namespace llvm {
@@ -23,6 +24,10 @@ bool match(const SCEV *S, const Pattern &P) {
2324
return P.match(S);
2425
}
2526

27+
template <typename Pattern> bool match(SCEVUse U, const Pattern &P) {
28+
return match(U.getPointer(), P);
29+
}
30+
2631
template <typename Predicate> struct cst_pred_ty : public Predicate {
2732
bool match(const SCEV *S) {
2833
assert((isa<SCEVCouldNotCompute>(S) || !S->getType()->isVectorTy()) &&

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10702,7 +10702,8 @@ ScalarEvolution::ExitLimit ScalarEvolution::howFarToZero(SCEVUse V,
1070210702
if (!CountDown && !isKnownNonNegative(StepWLG))
1070310703
return getCouldNotCompute();
1070410704

10705-
const SCEV *Distance = CountDown ? Start : getNegativeSCEV(Start);
10705+
const SCEV *Distance =
10706+
CountDown ? Start : getNegativeSCEV(Start).getPointer();
1070610707
// Handle unitary steps, which cannot wraparound.
1070710708
// 1*N = -Start; -1*N = Start (mod 2^BW), so:
1070810709
// N = Distance (as unsigned)
@@ -10745,8 +10746,8 @@ ScalarEvolution::ExitLimit ScalarEvolution::howFarToZero(SCEVUse V,
1074510746
if (!loopIsFiniteByAssumption(L) && !isKnownNonZero(StepWLG))
1074610747
return getCouldNotCompute();
1074710748

10748-
SCEVUse Exact =
10749-
getUDivExpr(Distance, CountDown ? getNegativeSCEV(Step) : Step);
10749+
SCEVUse Exact = getUDivExpr(
10750+
Distance, CountDown ? getNegativeSCEV(Step).getPointer() : Step);
1075010751
SCEVUse ConstantMax = getCouldNotCompute();
1075110752
if (Exact != getCouldNotCompute()) {
1075210753
APInt MaxInt = getUnsignedRangeMax(applyLoopGuards(Exact, Guards));

0 commit comments

Comments
 (0)