Skip to content

Commit 29cf866

Browse files
fhahngithub-actions[bot]
authored andcommitted
Automerge: [SCEV] Add m_scev_UndefOrPoison (NFC). (#170740)
Add matcher for SCEVUnknown wrapping undef or poison. PR: llvm/llvm-project#170740
2 parents fb68f1e + 113f058 commit 29cf866

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,19 @@ m_scev_AffineAddRec(const Op0_t &Op0, const Op1_t &Op1, const Loop_t &L) {
380380
return SCEVAffineAddRec_match<Op0_t, Op1_t, Loop_t>(Op0, Op1, L);
381381
}
382382

383+
struct is_undef_or_poison {
384+
bool match(const SCEV *S) const {
385+
const SCEVUnknown *Unknown;
386+
return SCEVPatternMatch::match(S, m_SCEVUnknown(Unknown)) &&
387+
isa<UndefValue>(Unknown->getValue());
388+
}
389+
};
390+
391+
/// Match an SCEVUnknown wrapping undef or poison.
392+
inline is_undef_or_poison m_scev_UndefOrPoison() {
393+
return is_undef_or_poison();
394+
}
395+
383396
} // namespace SCEVPatternMatch
384397
} // namespace llvm
385398

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,9 +2998,8 @@ void LoopAccessInfo::collectStridedAccess(Value *MemAccess) {
29982998
if (!StrideExpr)
29992999
return;
30003000

3001-
if (auto *Unknown = dyn_cast<SCEVUnknown>(StrideExpr))
3002-
if (isa<UndefValue>(Unknown->getValue()))
3003-
return;
3001+
if (match(StrideExpr, m_scev_UndefOrPoison()))
3002+
return;
30043003

30053004
LLVM_DEBUG(dbgs() << "LAA: Found a strided access that is a candidate for "
30063005
"versioning:");

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13695,11 +13695,8 @@ SCEVAddRecExpr::getPostIncExpr(ScalarEvolution &SE) const {
1369513695

1369613696
// Return true when S contains at least an undef value.
1369713697
bool ScalarEvolution::containsUndefs(const SCEV *S) const {
13698-
return SCEVExprContains(S, [](const SCEV *S) {
13699-
if (const auto *SU = dyn_cast<SCEVUnknown>(S))
13700-
return isa<UndefValue>(SU->getValue());
13701-
return false;
13702-
});
13698+
return SCEVExprContains(
13699+
S, [](const SCEV *S) { return match(S, m_scev_UndefOrPoison()); });
1370313700
}
1370413701

1370513702
// Return true when S contains a value that is a nullptr.

0 commit comments

Comments
 (0)