[PATCH] D148210: [InstCombine] icmp(MulC * X * Y, C) --> icmp(X * Y, C)

Jun Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 13 03:29:02 PDT 2023


junaire added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:2032
+    if (match(Mul, m_c_Mul(m_BinOp(InnerMul), m_Value(Y))) &&
+        match(InnerMul, m_c_Mul(m_APInt(MulC), m_Value(X)))) {
+      if (Mul->hasNoSignedWrap() && InnerMul->hasNoSignedWrap() &&
----------------
There's one corner case this doesn't handle, consider:
`2 * X * Y > 0`
2 * X will be folded into a `shl`. I'll appreciate it if anyone can suggest a more general way to match this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148210



More information about the llvm-commits mailing list