[PATCH] D159203: [InstCombine] Fold (A/-B)==(A/B) to (A/B)==0

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 18:31:43 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:5239
+    if (match(Op0, m_OneUse(m_SDiv(m_Value(A), m_OneUse(m_Neg(m_Value(B)))))) &&
+        match(Op1, m_SDiv(m_Specific(A), m_Specific(B)))) {
+      // Check if A is known to be != INT_MIN
----------------
This is a commutative pattern. Think should either put in a lambda so you can pass op0,op1 then op1,op0 or `m_c_ICmp(Pred, Pattern0, Pattern1)`.


================
Comment at: llvm/test/Transforms/InstCombine/icmp-sdiv-sdiv.ll:55
   %d2 = sdiv i6 %x, %C
   %c = icmp ne i6 %d1, %d2
   ret i1 %c
----------------
Can you flip the `d1`/`d2` operands in a few of these tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159203



More information about the llvm-commits mailing list