[llvm] [ValueTracking] Add rotate idiom to haveNoCommonBitsSet special cases (PR #122165)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 8 14:21:47 PST 2025
================
@@ -229,6 +229,19 @@ static bool haveNoCommonBitsSetSpecialCases(const Value *LHS, const Value *RHS,
return true;
}
+ // Look for: (X << V) op (Y >> (BitWidth - V))
+ // or (X >> V) op (Y << (BitWidth - V))
+ {
+ const Value *V;
+ const APInt *R;
+ if (((match(RHS, m_Shl(m_Value(), m_Sub(m_APInt(R), m_Value(V)))) &&
+ match(LHS, m_LShr(m_Value(), m_Specific(V)))) ||
+ (match(RHS, m_LShr(m_Value(), m_Sub(m_APInt(R), m_Value(V)))) &&
+ match(LHS, m_Shl(m_Value(), m_Specific(V))))) &&
+ R->uge(LHS->getType()->getScalarType()->getIntegerBitWidth()))
----------------
goldsteinn wrote:
Think you are missing check that the `shl` and `lshr` are operating on the same `X`. I.e `m_Value(X)` in the `m_Shl` matchers and `m_Specific(X)` in the `m_LShr` matchers.
https://github.com/llvm/llvm-project/pull/122165
More information about the llvm-commits
mailing list