This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re : Re : OR in Generic or Gimple


On 20/04/11 09:40, charfi asma wrote:
> 

>> 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.
> 
> Andrew, 1!=0 is true ;) and the OR expression is if ((y > 1) || (y < 9)) that is 
> also true. I did not say that gcc make a mistake in evaluating this but I would 
> like to know how it is translated in gimple which generic tree code are used, 
> where it does this transfo from if ((y > 1) || (y < 9)) to (1!=0) ? in the 
> gimplify function or when it builds generic if it builds it ....

It looks like constant folding.
Hard to say, because no gcc version I have does it.

With 4.6 I get:

    x = 6;
    y = x + 10;
    if (y == 1) goto <D.2069>; else goto <D.2071>;
    <D.2071>:
    if (y == 0) goto <D.2069>; else goto <D.2070>;
    <D.2069>:
    D.2072 = 10;
    return D.2072;
    <D.2070>:
    D.2072 = 0;
    return D.2072;

Are you using optimization?

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]