This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Fix non-canonical RTL PLUS expressions.
- From: Roger Sayle <roger at eyesopen dot com>
- To: Paul Brook <paul at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 9 Jan 2004 19:34:33 -0700 (MST)
- Subject: Re: [patch] Fix non-canonical RTL PLUS expressions.
On Fri, 9 Jan 2004, Paul Brook wrote:
> When all its operands are negated, simplify_plus_minus builds an RTL
> expression which is not in canonical form. For example it produces
> (neg (plus a b)) instead of (minus (neg a) b).
Unfortunately, your patch doesn't completely solve the canonicalization
problem. When n_ops is greater than two, you'll still generate a
NEG expr around either a PLUS or MINUS.
Instead of the "neg (plus (plus A B) C)" that is currently generated
your patch produces the slightly better "(minus (neg (plus A B)) C)".
it should however generate the canonical "(minus (minus (neg A) B) C)".
I believe negating the first term/leaf, and inverting the sense of
ops[i].neg should be sufficient, except with then term being subtracted
is a constant when we need to add the negative constant.
Roger
--