GCC internals chapter 16.14

Ian Lance Taylor iant@google.com
Wed Aug 19 20:54:00 GMT 2009


"Panu-Kristian Poiksalo" <panu.poiksalo@vlsi.fi> writes:

> Sorry to bother you with an idiotic question, but I might have
> misunderstood something rather profoundly.
>
> See GCC internals chapter 16.14 "Canonicalization of Instructions".
> In item #4 of the list of canonicalizations, it is stated:
> "(plus (mult (neg A) B) C) is canonicalized as (minus A (mult B C))."
>
> Now, that looks a bit strange. Does that mean that
> ((-a) * b) + c)  is-equal-to  (a - (b * c))
>
> because it doesn't seem that way if I substitute a=3, b=5, c=7 I get
> ((-3) * 5) + 7) = (-15 + 7) = -8  and
> (3 - (5 * 7)) = (3 - (35)) = -32.

You're right, the docs are wrong.  It should say that (plus (mult (neg
B) C) A) is canonicalized as (minus A (mult B C)).  I'll fix it.
Thanks.

Ian



More information about the Gcc-help mailing list