[PATCH] Fix fold-const breakage

Jakub Jelinek jakub@redhat.com
Thu Feb 22 15:07:00 GMT 2001


On Thu, Feb 22, 2001 at 05:55:58PM -0500, Richard Kenner wrote:
>     The reason is that it is not safe to optimize:
>     ( x * -3 - y * 3 ) / 12 into x / -4 - y / 4 which was extract_muldiv trying
>     (since extract_muldiv gave non-zero for both operands).
> 
> -      if (t1 != 0 && t2 != 0)
> +      if (t1 != 0 && t2 != 0
> +	  && (code == MULT_EXPR
> +	      /* If not multiplication, we can only this if both operands
> +		 are divisible by c.  */
> +	      || (multiple_of_p (ctype, op0, c)
> +		  && multiple_of_p (ctype, op1, c))))
> 
> This is a pretty major pessimization of the code.  Isn't there some finer
> test that can be made here?

If op0 or op1 is not multiple of c, is this transformation ever safe (I can
think just about EXACT_DIV_EXPR)?

> 
> +	  if (TYPE_PRECISION (TREE_TYPE (size_one_node))
> +	      > TREE_INT_CST_LOW (op1)
> +	      && TREE_INT_CST_HIGH (op1) == 0
> 
> This can be done with compare_tree_int.

Ok, will change that (and the code in extract_muldiv I copied it from).

	Jakub



More information about the Gcc-patches mailing list