Skip to content

Commit 1d0a32e

Browse files
committed
[LSR/SCEVPM] Introduce and use m_SCEVVScale
1 parent eebabb8 commit 1d0a32e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ inline class_match<const SCEV> m_SCEV() { return class_match<const SCEV>(); }
6464
inline class_match<const SCEVConstant> m_SCEVConstant() {
6565
return class_match<const SCEVConstant>();
6666
}
67+
inline class_match<const SCEVVScale> m_SCEVVScale() {
68+
return class_match<const SCEVVScale>();
69+
}
6770

6871
template <typename Class> struct bind_ty {
6972
Class *&VR;

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,6 @@ static const SCEV *getExactSDiv(const SCEV *LHS, const SCEV *RHS,
924924
/// value, and mutate S to point to a new SCEV with that value excluded.
925925
static Immediate ExtractImmediate(const SCEV *&S, ScalarEvolution &SE) {
926926
const APInt *C;
927-
const SCEV *Op1;
928927
if (match(S, m_scev_APInt(C))) {
929928
if (C->getSignificantBits() <= 64) {
930929
S = SE.getConstant(S->getType(), 0);
@@ -945,8 +944,7 @@ static Immediate ExtractImmediate(const SCEV *&S, ScalarEvolution &SE) {
945944
SCEV::FlagAnyWrap);
946945
return Result;
947946
} else if (EnableVScaleImmediates &&
948-
match(S, m_scev_Mul(m_scev_APInt(C), m_SCEV(Op1))) &&
949-
isa<SCEVVScale>(Op1)) {
947+
match(S, m_scev_Mul(m_scev_APInt(C), m_SCEVVScale()))) {
950948
S = SE.getConstant(S->getType(), 0);
951949
return Immediate::getScalable(C->getSExtValue());
952950
}
@@ -3332,9 +3330,8 @@ static bool canFoldIVIncExpr(const SCEV *IncExpr, Instruction *UserInst,
33323330
} else {
33333331
// Look for mul(vscale, constant), to detect a scalable offset.
33343332
const APInt *C;
3335-
const SCEV *Op1;
3336-
if (!match(IncExpr, m_scev_Mul(m_scev_APInt(C), m_SCEV(Op1))) ||
3337-
!isa<SCEVVScale>(Op1) || C->getSignificantBits() > 64)
3333+
if (!match(IncExpr, m_scev_Mul(m_scev_APInt(C), m_SCEVVScale())) ||
3334+
C->getSignificantBits() > 64)
33383335
return false;
33393336
IncOffset = Immediate::getScalable(C->getSExtValue());
33403337
}

0 commit comments

Comments
 (0)