[PATCH] D157312: [InstCombine] Add transforms for `(or/and (icmp eq/ne X,0),(icmp eq/ne X,Pow2OrZero))`

Allen zhong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 24 19:33:17 PDT 2023


Allen added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:743
+// (or (icmp eq X, 0), (icmp eq X, Pow2OrZero))
+//      -> (icmp eq (and X, Pow2), X)
+// (and (icmp ne X, 0), (icmp ne X, Pow2OrZero))
----------------
nit: Pow2 -> Pow2OrZero


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:764
+  // RHS: (icmp eq/ne X, Pow2OrZero)
+  if (!match(LHS, m_ICmp(Pred, m_Value(Op), m_Zero())) ||
+      !match(RHS, m_c_ICmp(Pred, m_Specific(Op), m_Value(Pow2))) ||
----------------
goldstein.w.n wrote:
> Allen wrote:
> > LHS and RHS are commutative . Do we need to consider it? 
> Above we swap `LHS`/`RHS` so that `LHS` is the comparison against zero: L757.
> 
> If you are refering to not using `m_c_ICmp` here then its also no issue b.c of canonicalization.
oh, I missed the swap, thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157312/new/

https://reviews.llvm.org/D157312



More information about the llvm-commits mailing list