[llvm] [InstCombine] Canonicalize nested sub & add with an inner constant (PR #191022)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 8 10:59:16 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/Transforms/InstCombine/InstCombineAddSub.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/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index f0ba5bc21..65c9479ae 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -1526,9 +1526,9 @@ static Instruction *foldBoxMultiply(BinaryOperator &I) {
/// Canonicalize a nested add/sub with a constant on the inner RHS by
/// sinking the constant to the outer RHS.
/// (X +/- C) +/- Y -> (X +/- Y) +/- C
-static Instruction
-*canonicalizeNestedAddSubWithConstant(BinaryOperator &I,
- InstCombiner::BuilderTy &Builder) {
+static Instruction *
+canonicalizeNestedAddSubWithConstant(BinaryOperator &I,
+ InstCombiner::BuilderTy &Builder) {
assert((I.getOpcode() == Instruction::Add ||
I.getOpcode() == Instruction::Sub) &&
@@ -1550,8 +1550,7 @@ static Instruction
else
return nullptr;
- Value *XY = IsOuterAdd ? Builder.CreateAdd(X, Y)
- : Builder.CreateSub(X, Y);
+ Value *XY = IsOuterAdd ? Builder.CreateAdd(X, Y) : Builder.CreateSub(X, Y);
return IsInnerAdd ? BinaryOperator::CreateAdd(XY, C)
: BinaryOperator::CreateSub(XY, C);
``````````
</details>
https://github.com/llvm/llvm-project/pull/191022
More information about the llvm-commits
mailing list