[PATCH] D130433: [InstCombine] Add fold for redundant sign bits count comparison

David Majnemer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 08:54:23 PDT 2022


majnemer added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1675-1680
+  if (!match(Y, m_AShr(m_Specific(X), m_APInt(ShiftC)))) {
+    if (match(X, m_AShr(m_Specific(Y), m_APInt(ShiftC))))
+      std::swap(X, Y);
+    else
+      return nullptr;
+  }
----------------
Would this be simpler as:

  if (!match(Xor, m_c_Xor(m_Value(X), m_Ashr(m_Deferred(X), m_APInt(ShiftC)))) {
    return nullptr;
  }


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1684
+  unsigned BitWidth = XType->getScalarSizeInBits();
+  if (Shift <= 2 || Shift > BitWidth || C.logBase2() != (BitWidth - Shift + 1))
+    return nullptr;
----------------
Why 2?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130433



More information about the llvm-commits mailing list