[PATCH] D109155: [InstCombine] Fold BW/2+1 tops bits are same pattern

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 2 09:58:44 PDT 2021


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:4510
+  if (match(&I,
+            m_c_ICmp(
+                TPred, m_Trunc(m_LShr(m_Value(A), m_SpecificInt(BitWidth))),
----------------
We don't need the commutative matcher (and the regression test shows this). That's because we always canonicalize the 'ashr' as op0 and 'trunc' as op1 based on `getComplexity`.

Actually, we don't need to rematch the icmp at all if we handle both predicates - see next comment.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:4514
+      A->getType()->getScalarSizeInBits() == BitWidth * 2 &&
+      TPred == ICmpInst::ICMP_EQ &&
+      (I.getOperand(0)->hasOneUse() || I.getOperand(1)->hasOneUse())) {
----------------
We should handle ICMP_NE for symmetry. Flip from ULT to UGE?
https://alive2.llvm.org/ce/z/_fEQ9P


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

https://reviews.llvm.org/D109155



More information about the llvm-commits mailing list