[PATCH] reorganize simplify_const_relational_operation

Paolo Bonzini bonzini@gnu.org
Tue Sep 25 15:59:00 GMT 2007


> 'result' without 's'.  The comment doesn't cover LTGT.

LTGT is considered an unordered comparison. :-)  I'll add "including LTGT".

>   if ((! HONOR_NANS (GET_MODE (trueop0))
>        || code == UNEQ || code == UNLE || code == UNGE || code == LTGT
>        || ((code == LT || code == GT) && ! HONOR_SNANS (GET_MODE (trueop0)))
> 
> would be clearer.

Ok.

> +	  /* INTVAL/UINTVAL is the same for mmin (it is 0 for unsigned).  */
> 
> Slightly incorrect, (UINTVAL(mmin)>>b) != (INTVAL(mmin)>>b) for signed mmin.

I meant: mmin is always 0 for unsigned and, since INTVAL(0) >> 
(sign_copies - 1) is the same as UINTVAL(0) >> (sign_copies - 1), we can 
always use INTVAL for mmin.

> +	  mmin = INTVAL (mmin_rtx) >> (sign_copies - 1);
> +	  if (sign)
> +	    mmax = INTVAL (mmax_rtx) >> (sign_copies - 1);
> +	  else
> +	    mmax = UINTVAL (mmax_rtx) >> (sign_copies - 1);
> 
> Can't we always use UINTVAL for mmax_rtx?

Yes, we can.  Good catch.

> 	  /* INTVAL/UINTVAL are equivalent for unsigned mmin.  */
> 	  mmin = INTVAL (mmin_rtx) >> (sign_copies - 1);
> 	  /* UINTVAL/INTVAL are equivalent for signed mmax.  */
>           mmax = UINTVAL (mmax_rtx) >> (sign_copies - 1);

I'll write:

   /* Since unsigned mmin will never be interpreted as negative, use
      INTVAL (and a sign-extending right shift).  */
   mmin = INTVAL (mmin_rtx) >> (sign_copies - 1);
   /* Since signed mmax will always be positive, use UINTVAL (and
      a zero-extending right shift).  */

Do you prefer arithmetic/logical right shift instead?

> 
> +      /* See if the first operand is an IOR with a constant.  If so, we
> +	 may be able to determine the result of this comparison.  */
> +      if (GET_CODE (op0) == IOR)
> +        {
> +	  rtx inner_const = avoid_constant_pool_reference (XEXP (op0, 1));
> +	  if (GET_CODE (inner_const) == CONST_INT)
> +	    {
> 
> I presume that we can be sure that inner_const is not zero?

Yes, avoid_constant_pool_reference returns its argument if it cannot do 
anything.

I'll wait for your comments and then rebootstrap/commit.

Paolo



More information about the Gcc-patches mailing list