-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[SCEV] Add m_scev_UndefOrPoison (NFC). #170740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add matcher for SCEVUnknown wrapping undef or poison.
Member
|
@llvm/pr-subscribers-llvm-analysis Author: Florian Hahn (fhahn) ChangesAdd matcher for SCEVUnknown wrapping undef or poison. Full diff: https://github.com/llvm/llvm-project/pull/170740.diff 3 Files Affected:
diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h b/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h
index 9354eef98fe91..f285eacc4c565 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h
@@ -380,6 +380,19 @@ m_scev_AffineAddRec(const Op0_t &Op0, const Op1_t &Op1, const Loop_t &L) {
return SCEVAffineAddRec_match<Op0_t, Op1_t, Loop_t>(Op0, Op1, L);
}
+struct is_undef_or_poison {
+ bool match(const SCEV *S) const {
+ const SCEVUnknown *Unknown;
+ return SCEVPatternMatch::match(S, m_SCEVUnknown(Unknown)) &&
+ isa<UndefValue>(Unknown->getValue());
+ }
+};
+
+/// Match an SCEVUnknown wrapping undef or poison.
+inline is_undef_or_poison m_scev_UndefOrPoison() {
+ return is_undef_or_poison();
+}
+
} // namespace SCEVPatternMatch
} // namespace llvm
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 5d88e5f54e3d6..df793de7c817b 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -2998,9 +2998,8 @@ void LoopAccessInfo::collectStridedAccess(Value *MemAccess) {
if (!StrideExpr)
return;
- if (auto *Unknown = dyn_cast<SCEVUnknown>(StrideExpr))
- if (isa<UndefValue>(Unknown->getValue()))
- return;
+ if (match(StrideExpr, m_scev_UndefOrPoison()))
+ return;
LLVM_DEBUG(dbgs() << "LAA: Found a strided access that is a candidate for "
"versioning:");
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 1d7a8b981b5ee..e1f90264be7a2 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -13695,11 +13695,8 @@ SCEVAddRecExpr::getPostIncExpr(ScalarEvolution &SE) const {
// Return true when S contains at least an undef value.
bool ScalarEvolution::containsUndefs(const SCEV *S) const {
- return SCEVExprContains(S, [](const SCEV *S) {
- if (const auto *SU = dyn_cast<SCEVUnknown>(S))
- return isa<UndefValue>(SU->getValue());
- return false;
- });
+ return SCEVExprContains(
+ S, [](const SCEV *S) { return match(S, m_scev_UndefOrPoison()); });
}
// Return true when S contains a value that is a nullptr.
|
preames
approved these changes
Dec 4, 2025
Collaborator
preames
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Dec 5, 2025
Add matcher for SCEVUnknown wrapping undef or poison. PR: llvm/llvm-project#170740
honeygoyal
pushed a commit
to honeygoyal/llvm-project
that referenced
this pull request
Dec 9, 2025
Add matcher for SCEVUnknown wrapping undef or poison. PR: llvm#170740
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add matcher for SCEVUnknown wrapping undef or poison.