Re: Re : OR in Generic or Gimple

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 20/04/11 09:21, charfi asma wrote:
> 
> 
> 
> 
> ----- Message d'origine ----
> De : Andrew Haley <aph@xxxxxxxxxx>
> À : gcc-help@xxxxxxxxxxx
> Envoyé le : Mar 19 avril 2011, 18h 53min 58s
> Objet : Re: OR in Generic or Gimple
> 
> On 04/19/2011 05:48 PM, charfi asma wrote:
>> Hello,
>> In my front end I would like to translate to generic the OR operation (if ( y 
>> =a) || (y=b)) ...
>> I tried to look at the gimple generated from this C++ program
>>
>> int main()
>> {
>> int x=6;
>> int y = x+10;
>> if ((y == 1) || (y==0))
>>   return 10;
>> else
>>   return 0;
>> }
>>
>>
>> I found this:
>>
>>
>> int main() ()
>> {
>>   unsigned int y.0;
>>   unsigned int D.2070;
>>   int D.2073;
>>
>>   {
>>     int x;
>>     int y;
>>
>>     x = 6;
>>     y = x + 10;
>>     y.0 = (unsigned int) y;
>>     D.2070 = y.0 + 4294967295;
>>     if (D.2070 <= 1) goto <D.2071>; else goto <D.2072>;
>>     <D.2071>:
>>     D.2073 = 10;
>>     return D.2073;
>>     <D.2072>:
>>     D.2073 = 0;
>>     return D.2073;
>>   }
>>   D.2073 = 0;
>>   return D.2073;
>> }
>>
>> I do not really understand how gimple is generated for the OR test.
> 
> I don't understand it either.  I think it's a bug.  I get:
> 
> int main() ()
> {
>   unsigned int y.0;
>   int D.2099;
> 
>   {
>     int x;
>     int y;
> 
>     x = 6;
>     y = x + 10;
>     y.0 = (unsigned int) y;
>     if (y.0 <= 1) goto <D.2097>; else goto <D.2098>;
>     <D.2097>:
>     D.2099 = 10;
>     return D.2099;
>     <D.2098>:
>     D.2099 = 0;
>     return D.2099;
>   }
>   D.2099 = 0;
>   return D.2099;
> }
> 
> Andrew.
> 
> Hello Andrew,
> 
> I get this using both gcc4.4.1 and gcc4.6.
> I even tried with gcc (compile c file) instead of g++ (compile c++ file), but I 
> get the same gimple.
> 
> however when I change values:
> int x=6;
> int y =x+10;
> if ((y > 1) || (y < 9)) ....
> 
> I get this:
> 
> int main() ()
> {
>   int D.2071;
> 
>   {
>     int x;
>     int y;
> 
>     x = 6;
>     y = x + 10;
>     if (1 != 0) goto <D.2069>; else goto <D.2070>;
>     <D.2069>:
>     D.2071 = 10;
>     return D.2071;
>     <D.2070>:
>     D.2071 = 0;
>     return D.2071;
>   }
>   D.2071 = 0;
>   return D.2071;
> }
> 
> Any way, did so know which generic tree code or gimple statement used to 
> generate this ? why if ((y > 1) || (y < 9)) is translated to if (1!=0) ??

Well, we know that x == 6, so y == 6 + 10.  Therefore we know that
(y == 1) || (y==0) is false.

So, the expression (y == 1) || (y==0) can be replaced with 1 != 0 .

Andrew.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux