diff options
author | Florian Hahn <flo@fhahn.com> | 2025-07-31 16:33:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-31 16:33:25 +0100 |
commit | 99d70e09a9676d63513a496f52acf93ca7167f00 (patch) | |
tree | 059b1757bf6afbe68d5ef59136aaa4b8411c47f0 /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | |
parent | bd041389351dc920a6b7a6cc6703e30af5d0ad23 (diff) | |
download | llvm-99d70e09a9676d63513a496f52acf93ca7167f00.zip llvm-99d70e09a9676d63513a496f52acf93ca7167f00.tar.gz llvm-99d70e09a9676d63513a496f52acf93ca7167f00.tar.bz2 |
[SCEV] Allow adds of constants in tryToReuseLCSSAPhi. (#150693)
Update the logic added in
https://github.com/llvm/llvm-project/pull/147824 to also allow adds of
constants. There are a number of cases where this can help remove
redundant phis and replace some computation with a ptrtoint (which
likely is free in the backend).
PR: https://github.com/llvm/llvm-project/pull/150693
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index 571fa11..1eb8996 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -1249,7 +1249,8 @@ Value *SCEVExpander::tryToReuseLCSSAPhi(const SCEVAddRecExpr *S) { // offset, if the offset is simpler. const SCEV *Diff = SE.getMinusSCEV(S, ExitSCEV); const SCEV *Op = Diff; - match(Diff, m_scev_Mul(m_scev_AllOnes(), m_SCEV(Op))); + match(Op, m_scev_Add(m_SCEVConstant(), m_SCEV(Op))); + match(Op, m_scev_Mul(m_scev_AllOnes(), m_SCEV(Op))); match(Op, m_scev_PtrToInt(m_SCEV(Op))); if (!isa<SCEVConstant, SCEVUnknown>(Op)) continue; |