[llvm] [InstCombine] Simplification for (-a * b) / (a * b). (PR #71768)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 01:20:14 PST 2023


================
@@ -1544,6 +1544,14 @@ Instruction *InstCombinerImpl::visitSDiv(BinaryOperator &I) {
     }
   }
 
+  // -X / X --> X == INT_MIN ? 1 : -1
+  if ((match(Op0, m_Sub(m_Zero(), m_Value(X))) && match(Op1, m_Specific(X)))) {
----------------
nikic wrote:

That's because you removed the assignment to `X` but are still using it. You need to use Op0 or Op1 instead.

https://github.com/llvm/llvm-project/pull/71768


More information about the llvm-commits mailing list