[llvm] [InstCombine] Fold commuted add of udiv/urem by two (#206272) (PR #207249)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 2 11:54: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/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 266a22370..ebc48123c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -1199,7 +1199,7 @@ Value *InstCombinerImpl::SimplifyAddWithRemainder(BinaryOperator &I) {
Div = LHS, C1 = APInt(I.getType()->getScalarSizeInBits(), 1);
if (!RHS->hasOneUse() || !MatchMul(RHS, Rem, C2))
Rem = RHS, C2 = APInt(I.getType()->getScalarSizeInBits(), 1);
- // The remainder may be spelled `and X, lowmask` (rem by a power of two),
+ // The remainder may be spelled `and X, lowmask` (rem by a power of two),
// not just urem/srem, so m_IRem alone misses the commuted form
// `add (and X, C), (lshr X, N)`.
// Detect any remainder form here so it lands in Rem.
``````````
</details>
https://github.com/llvm/llvm-project/pull/207249
More information about the llvm-commits
mailing list