This is the mail archive of the gcc-patches@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]

Re: A new patch for floating point conditional mov on PPo


John Wehle writes:

>> Another output_int_test_compare_fcmov issue is that it clobbers cc0.
>> 
>> Consider:
>> 
>>   int a;
>>   int b;
>>   double d;
>>   double e;
>>   int g;
>>   int h;
>> 
>>   if (a < b)
>>     d = f;
>> 
>>   if (a < b)
>>     g = h;
>> 

H.J. Lu writes:

> It seems to me that the second (a < b) is never deleted even for
> 
> int
> foo (int x, int i, int y, int z)
> {
>   if (y > z)
>     x = 0;
> 
>   if (y > z)
>     i = 0;
> 
>   return x * i;
> }

In your example you are moving zero into x which notice_update_cc
considers to clobber cc0.  As a result the second comparison isn't
deleted.  This is currently only the case when moving a constant,
and this may change in the future as notice_update_cc becomes
smarter (since moving a constant on the i386 processor doesn't
really clobber cc0).

> I think it is a good thing since the compiler may not know if
> the body of if_then_else will clobber cc0. If there is a way
> to tell the compiler about clobbering cc0, we just tell the
> compiler that the fp conditional move may clobber cc0.

It isn't safe to assume that the second comparison will not be
removed.  You must explicitly tell gcc when you clobber cc0,
usually this is handled in notice_update_cc.

-- John
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------



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