Fix PR 22018

Eric Botcazou ebotcazou@libertysurf.fr
Wed Jun 15 14:02:00 GMT 2005


> +   /* If the operation overflowed but neither VAL1 nor VAL2 are
> +      overflown, return -INF or +INF depending on whether VAL1 CODE
> +      VAL2 is a growing function or not.  */
> +   if (TREE_OVERFLOW (res)
> +       && !TREE_OVERFLOW (val1)
> +       && !TREE_OVERFLOW (val2))
> +     {
> +       bool grows = false;
> +       int sgn1 = tree_int_cst_sgn (val1);
> +       int sgn2 = tree_int_cst_sgn (val2);
> +
> +       /* Notice that we only need to handle the restricted set of
> + 	 operations handled by extract_range_from_binary_expr.  */
> +       if (((code == PLUS_EXPR || code == MAX_EXPR) && sgn2 >= 0)
> + 	  || (code == MULT_EXPR && sgn1 == sgn2)
> + 	  || (code == MINUS_EXPR && sgn2 < 0))
> + 	grows = true;
> +
> +       if (grows)
> + 	return TYPE_MAX_VALUE (TREE_TYPE (res));
> +       else
> + 	return TYPE_MIN_VALUE (TREE_TYPE (res));
> +     }
> +
> +   return res;
> + }

I think you should add a comment explaining the dissymmetry in your code for 
PLUS_EXPR and the dis-antisymmetry for MINUS_EXPR.  IMHO it's not trivial 
to see that it is correct.

Another strange thing is the dissymmetry MAX_EXPR/TYPE_MAX and 
MIN_EXPR/TYPE_MIN: why do you need to test the sign for MAX_EXPR and not for 
MIN_EXPR?

I'm bootstrapping it on SPARC with HOST_BITS_PER_WIDE_INT==32.

-- 
Eric Botcazou



More information about the Gcc-patches mailing list