[llvm] [InstCombine] Fold `(shl ShVal, (X + 1) & (Width-1)) | (lshr ShVal, (X & Width-1) ^ (Width-1))` --> `fshl(ShVal, ShVal, X+1)` (PR #214035)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 01:55:46 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/InstCombineAndOrXor.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/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 49a5c24f2..c98bf20d1 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -3013,7 +3013,8 @@ InstCombinerImpl::convertOrOfShiftsToFunnelShift(Instruction &Or) {
           match(R, m_And(m_Neg(m_Specific(X)), m_SpecificInt(Mask))))
         return X;
 
-      // (shl ShVal,(X+1) & (Width-1)) | (lshr ShVal,((X & (Width-1)) ^ (Width-1)))
+      // (shl ShVal,(X+1) & (Width-1)) | (lshr ShVal,((X & (Width-1)) ^
+      // (Width-1)))
       {
         Value *ShAmt = nullptr;
         if (match(L, m_c_And(m_Value(ShAmt), m_SpecificInt(Mask))) &&

``````````

</details>


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


More information about the llvm-commits mailing list