[PATCH] D110488: [InstCombine] Canonicalize ((X & -X) - 1) --> (~X & (X - 1)) (PR51784)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 06:07:56 PDT 2022


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1420
+  // Forms all commutable operations, and simplifies ctpop -> cttz folds.
+  if (match(&I, m_c_Add(m_OneUse(m_c_And(m_Value(A),
+                                         m_OneUse(m_Neg(m_Deferred(A))))),
----------------
The -1 constant should always be canonicalized to operand 1 (RHS), so this doesn't really need to match m_c_Add. You could match each of LHS and RHS instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110488



More information about the llvm-commits mailing list