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] for PR 18219


On Mon, 1 Nov 2004, Zdenek Dvorak wrote:
> 	PR tree-optimization/18219
> 	* fold-const.c (fold): Reassociate also (x - mult) + mult and
> 	(mult - x) + mult.  Cast operands of expression after applying
> 	distributive law to the correct types.  Apply distributive law
> 	to a * c - b * c for all non-float types.

The constant folding bits of this patch are OK for mainline.


There was one curious (but safe) change however:

> *************** fold (tree expr)
> *** 6612,6621 ****
>   	      if (TREE_CODE (parg0) != MULT_EXPR
>   		  && TREE_CODE (parg1) == MULT_EXPR)
>   		return fold (build2 (PLUS_EXPR, type,
> ! 				     fold (build2 (PLUS_EXPR, type,
> ! 						   fold_convert (type, parg1),
> ! 						   fold_convert (type, marg))),
> ! 				     fold_convert (type, parg0)));
>   	    }
>
>   	  if (TREE_CODE (arg0) == MULT_EXPR && TREE_CODE (arg1) == MULT_EXPR)
> --- 6616,6626 ----
>   	      if (TREE_CODE (parg0) != MULT_EXPR
>   		  && TREE_CODE (parg1) == MULT_EXPR)
>   		return fold (build2 (PLUS_EXPR, type,
> ! 				     fold_convert (type, parg0),
> ! 				     fold (build2 (pcode, type,
> ! 						   fold_convert (type, marg),
> ! 						   fold_convert (type,
> ! 								 parg1)))));
>   	    }
>
>   	  if (TREE_CODE (arg0) == MULT_EXPR && TREE_CODE (arg1) == MULT_EXPR)

Here your change now generates "(plus (parg0) (foo))" instead of
"(plus (foo) (parg0))".  My guess is that you originally investigated
that the PLUS_EXPR needed to be "pcode", and swapped the order to keep
them in the same order as the original.  If instead it's that there's
another optimization that only recognizes "(plus X Y)" but not
"(plus Y X)", then that needs fixing.


Hopefully approving the "fold" bits will simplify the review process
for whoever looks at the tree-ssa-loop-ivopts.c changes.

Thanks,

Roger
--


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