[llvm] [SCEV] Generalize A + zext(-A + B) fold to A + zext(C + X) (PR #209160)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 05:28:05 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Analysis/ScalarEvolution.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index c3b2693fe..25bea2180 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -2825,12 +2825,11 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<SCEVUse> &Ops,
// NUW on `(-C) + (C + X) = X` proves that `C + X` did not wrap
// below zero, so `zext(C + X) == sext(C) + zext(X)`.
hasFlags(StrengthenNoWrapFlags(this, scAddExpr,
- {getConstant(-*C), Add},
- SCEV::FlagAnyWrap),
- SCEV::FlagNUW)) {
- return getAddExpr(
- A, getSignExtendExpr(getConstant(*C), B->getType()),
- getZeroExtendExpr(X, B->getType()));
+ {getConstant(-*C), Add},
+ SCEV::FlagAnyWrap),
+ SCEV::FlagNUW)) {
+ return getAddExpr(A, getSignExtendExpr(getConstant(*C), B->getType()),
+ getZeroExtendExpr(X, B->getType()));
}
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/209160
More information about the llvm-commits
mailing list