[PATCH] D73410: [InstCombine] Push negation through multiply (PR44234)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 14:09:03 PST 2020


nikic marked an inline comment as done.
nikic added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:940
+  // 0-(A*B)  =>  A*(0-B)
+  case Instruction::Mul:
+    if (Value *NegA = freelyNegateValue(I->getOperand(0)))
----------------
xbolva00 wrote:
> Not related to this change: 
> 
> Should we worry about recursion depth here? Probably not a issue in practise..
Due to the one-use restriction (which prevents degenerating to exponential walks) I'm not really worried about recursion here. It could in theory visit many instructions (if you have a thousand multiplies in a chain...), but will never result in super-linear runtime, which I think is the main concern.

But I can add a depth limit if desired.


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

https://reviews.llvm.org/D73410





More information about the llvm-commits mailing list