[patch] clean up make_range

Roger Sayle roger@eyesopen.com
Thu Jun 24 05:32:00 GMT 2004


On Wed, 23 Jun 2004, Eric Christopher wrote:
> 2004-06-23  Eric Christopher  <echristo@redhat.com>
>
>    * fold-const.c (make_range): Cleanup type checking through function.
>    Remove orig_type. Replace with checks to exp_type and arg0_type.

This is OK for mainline.


> This patch should have no semantic difference, it merely makes it a bit
> more clear what we're testing where.  The only part I'm still not clear
> on is this:
>
>  	     So we have to make sure that the original unsigned value will
>  	     be interpreted as positive.  */
> -	  if (TYPE_UNSIGNED (type) && ! TYPE_UNSIGNED (TREE_TYPE (exp)))
> +
> +	  if (!TYPE_UNSIGNED (exp_type) && TYPE_UNSIGNED (arg0_type))
>
> Which I've changed to be what it was testing before, however, it doesn't
> seem to match the comment above.

The comment makes sense once you realize that the "original unsigned
value" refers to arg0, and "exp" is the value after the type conversion.
The ambiguity is that make_range operates from outside-in, but the more
conversional interpretation of type conversion execution is inside-out.

Perhaps this would be clearer when rewritten as:

  If we're converting arg0 from an unsigned type, to exp, a signed type,
  we will be doing the compairson as unsigned....
  So we have to ensure that we will handle large unsigned values the
  same way that the current signed bounds treat negative values.  */

Then your revised line (and the following code) should make more sense:

  if (!TYPE_UNSIGNED (exp_type) && TYPE_UNSIGNED (arg0_type))



Thanks for the clean-up.  This code was far more confusing before.

Roger
--



More information about the Gcc-patches mailing list