[llvm] [InstCombine] Fold mul (lshr exact (X, 2^N + 1)), N -> add (X , lshr (X, N)) (PR #95042)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 11 07:31:07 PDT 2024


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 fade04f81da9db974204b9d7c58b4affd0422d6e 5c899c39404bfba8a1488c5fad6beabf50211f71 -- llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index 1a22155cbc..9f1231476a 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -260,8 +260,9 @@ Instruction *InstCombinerImpl::visitMul(BinaryOperator &I) {
     Value *NewOp;
     const APInt *ShiftC;
     const APInt *MulAP;
-    if (match(&I, m_Mul(m_OneUse(m_CombineOr(m_LShr(m_Value(NewOp), m_APInt(ShiftC)),
-                                    m_AShr(m_Value(NewOp), m_APInt(ShiftC)))),
+    if (match(&I, m_Mul(m_OneUse(m_CombineOr(
+                            m_LShr(m_Value(NewOp), m_APInt(ShiftC)),
+                            m_AShr(m_Value(NewOp), m_APInt(ShiftC)))),
                         m_APInt(MulAP)))) {
       if (BitWidth > 2 && (*MulAP - 1).isPowerOf2() &&
           MulAP->logBase2() == ShiftC->getZExtValue()) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/95042


More information about the llvm-commits mailing list