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]

Re: ia32: multiplication folding


  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


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