Re: question about assembly code

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

 



Olivier Maury <Olivier_maury@xxxxxxxxxx> writes:

> Ok there is one main difference when the value to be put on the stack
> is NAN : it is not put on the stack !
> The fldl instruction just do nothing (expected ?) and that's why
> instead of having two values on the FP stack I have only one value !
> Even if the intel documentation says nothing about that configuration
> I guess that's why the fcmove raise a FPE...
> What do you think ?

An fldl of NaN should put a value on the stack.

I don't know what is happening here.

Ian


> On 08/09/11 16:44, Ian Lance Taylor wrote:
>> Olivier Maury<Olivier_maury@xxxxxxxxxx>  writes:
>>
>>> I was wondering, is the following assembly code correct:
>>>       c94:       e8 fc ff ff ff          call   c95
>>> <load_param_def_given+0x1d1>
>>>       c99:       84 c0                   test   %al,%al
>>>       c9b:       dd 45 d0                fldl   -0x30(%ebp)
>>>       c9e:       dd 45 d8                fldl   -0x28(%ebp)
>>>       ca1:       da c9                   fcmove %st(1),%st
>>>       ca3:       dd d9                   fstp   %st(1)
>>>       ca5:       dd 5d d0                fstpl  -0x30(%ebp)
>>>       ca8:       89 f8                   mov    %edi,%eax
>>>
>>> This code is some optimized assembly code extracted from the object
>>> file using objdump. My concern here is that I have a test instruction
>>> without the corresponding jump !
>> The test instruction is setting the flags for the fcmove instruction.
>>
>>
>>> That piece of assembly comes from a code that look like:
>>> if (my_function(param1,&out_param))
>>>      value = out_param;
>>>
>>> with :
>>> out_param a double value that is not assigned with a default value
>>> and
>>> char my_function(long param1, double *out)
>>> {
>>>     char ret = 0;
>>>      ... do some stuff ...
>>>      if (some_property)
>>>     {
>>>         ... do some stuff ...
>>>         *out = a_value_computed;
>>>         ret = 1;
>>>     }
>>>     ....
>>>     return ret;
>>> }
>>>
>>> And taking that optimized code in a debugger it crash with a FPE from
>>> time to time because even if the my_function returns 0 it seems to do
>>> the assignement (value = out_param) with an unitialized out_param
>>> value !
>>>
>>> What do you think ? Am I doing something wrong or is it a gcc bug ?
>> It's pretty hard to say anything about an incomplete example.  However,
>> fcmove is a conditional move, so the code will only do the move if the
>> value returned is non-zero.  I don't see anything wrong in what you have
>> shown us.
>>
>> Ian


[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