[PATCH] D138814: [InstCombine] Combine lshr of add -> (a + b < a)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 6 08:42:26 PST 2023


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp:866
+  if (!match(ShiftAmt, m_APInt(ShAmtAPInt)) ||
+      !match(Add, m_Add(m_ZExt(m_Value(X)), m_ZExt(m_Value(Y)))))
+    return nullptr;
----------------
We should put m_OneUse() limits on the m_ZExt matches. Also, add a test where the zexts have extra use(s). 

That should avoid the +2 instruction count regression in the next patch. We are still potentially increasing instruction count with this transform, but the trade-off seems more reasonable if we can eliminate more of the intermediate instructions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138814



More information about the llvm-commits mailing list