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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 00:44:10 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:

Wouldn't we still want to use isKnownNegation() here? The INT_MIN check can be done on either operand, so that should work.

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


More information about the llvm-commits mailing list