This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]