On Sat, 12 Dec 2020, Jakub Jelinek via Gcc-patches wrote:
On Sat, Dec 12, 2020 at 01:25:39PM +0100, Marc Glisse wrote:
On Sat, 12 Dec 2020, Jakub Jelinek via Gcc-patches wrote:
This patch adds the ~(X - Y) -> ~X + Y simplification requested
in the PR (plus also ~(X + C) -> ~X + (-C) for constants C that can
be safely negated.
Would it have been wrong to produce ~X - C without caring about negating
(and then extending it to non-constants)?
Extending it to non-constants is what I wanted to avoid.
For ~(X + Y), because + is commutative, it wouldn't be a canonicalization
as it would pick more-less randomly whether to do ~X + Y or X + ~Y.
~X - Y or ~Y - X I guess.
Ok, I understand. But then in the constant case, why produce ~X + -C
instead of ~X - C (which I think doesn't need to care about negating), or
even ~C - X (one less operation)? Or do we already have a transformation
from ~X - C to ~C - X?
--
Marc Glisse