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

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 15 08:46:01 PDT 2026


================
@@ -3013,6 +3013,17 @@ 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)))
+      {
+        Value *ShAmt = nullptr;
+        if (match(L, m_c_And(m_Value(ShAmt), m_SpecificInt(Mask))) &&
+            match(ShAmt, m_c_Add(m_Value(X), m_SpecificInt(1))) &&
----------------
dtcxzyw wrote:

Use `m_Value(Value *&V, const Pattern &P)` and `m_One()`.


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


More information about the llvm-commits mailing list