[llvm] [InstCombine] Recognize more rotation patterns (PR #78107)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 14 11:27:32 PST 2024


================
@@ -2809,6 +2809,10 @@ static Instruction *matchFunnelShift(Instruction &Or, InstCombinerImpl &IC,
           match(R, m_And(m_Neg(m_Specific(X)), m_SpecificInt(Mask))))
         return X;
 
+      // (shl ShVal, X) | (lshr ShVal, ((-X) & (Width - 1)))
+      if (match(R, m_And(m_Neg(m_Specific(L)), m_SpecificInt(Mask))))
+        return L;
----------------
goldsteinn wrote:

Just as valid is `(shl ShVal, X & (Width - 1)) | (lshr ShVal, -X)`. No?
Not that it would be all that common, but could imagine `-X & (Width - 1)` being the simplified part.

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


More information about the llvm-commits mailing list