[llvm] [InstCombine] Simplifiy `(-x * y * -x)` into `(x * y * x)` (PR #72953)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 08:53:59 PST 2023


https://github.com/nikic commented:

As a high level note, the pattern handled here looks rather specific. There are variants on it, such as replacing the inner mul with a shl.

The general pattern would be a multiply where we have a negation on one side, and the other side is negatible (in the sense of `Negator::Negate`). This is actually how these patterns usually get handled, through a somewhat convoluted pathway where first the negation is hoisted outside the multiply and then the negator pushes it back in the other multiply operand. This fails if we don't have one use.

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


More information about the llvm-commits mailing list