[PATCH] reorganize simplify_const_relational_operation

Paolo Bonzini paolo.bonzini@lu.unisi.ch
Wed Sep 19 13:52:00 GMT 2007


Eric Botcazou wrote:
>> Ah, right, if we are comparing -128 (0xFFFFFF80) with 127 (0x0000007F)
>> we would already have high0 != high1.  I wonder if it is a bug in
>> double_int_scmp, which uses HOST_WIDE_INT for the low part in signed
>> comparisons.
> 
> No, it is correct there too:
> 
> typedef struct
> {
>   unsigned HOST_WIDE_INT low;
>   HOST_WIDE_INT high;
> } double_int;

int
double_int_scmp (double_int a, double_int b)
{
   if (a.high < b.high)
     return -1;
   if (a.high > b.high)
     return 1;
   if ((HOST_WIDE_INT) a.low < (HOST_WIDE_INT) b.low)  /* oops? */
     return -1;
   if ((HOST_WIDE_INT) a.low > (HOST_WIDE_INT) b.low)  /* oops? */
     return 1;

   return 0;
}

:-)

> Btw, I presume that your second patch eliminates this interesting 'else':

Yes.

Paolo



More information about the Gcc-patches mailing list