This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: ia32: multiplication folding
- To: Richard Henderson <rth at cygnus dot com>
- Subject: Re: ia32: multiplication folding
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Tue, 24 Aug 1999 00:54:36 -0600
- cc: gcc-patches at gcc dot gnu dot org
- Reply-To: law at cygnus dot com
In message <19990809164753.B7579@cygnus.com>you write:
> Does a bit of reassociation to help out loops like
>
> short a[n][2];
> int b[n][2];
> for (i = 0; i < n; ++i)
> b[i][const] += a[i][const];
>
> We're now able to see that the offsets from A and B are related by a
> constant factor of two, and so be able to unify the two givs to use
> a base + scaled index addressing mode.
>
>
> r~
>
>
>
> * fold-const.c (fold): Reassociate (+ (+ (* a b) c) (* d e))
> as (+ (+ (* a b) (* d e)) c). Factor a common power-of-two
> multiplicand out of (+ (* a b) (* c d)).
This is fine.
If you want you should feel free to extract the code I wrote to reassociate
a series of integer mults and submit it too :-)
(* (* (* a b) c) d) -> (* (* a b) (* c d))
See fold-const.c::reduce_expression_tree_depth in Cygnus's tree. It's loosely
patterned after cse.c::simplify_plus_minus, but without negation support (and
it works on trees of course).
jeff