> Am 08.01.2023 um 14:31 schrieb Paul Richard Thomas via Fortran 
> <fortran@gcc.gnu.org>:
> 
> Hi Thomas,
> 
> Following your off-line explanation that the seemingly empty looking
> assembly line forces an effective reload from memory, all is now clear.

It’s not a full fix (for register vars) and it’s ‚superior‘ to the call itself 
only because asm handling is implemented in a rather stupid way in the Alias 
oracle.  So I don’t think this is a „fix“ at all.

Richard 

> OK for mainline and for backporting as you see fit.
> 
> Thanks for the patch.
> 
> Paul
> 
> 
>> On Sat, 7 Jan 2023 at 15:46, Thomas Koenig via Fortran <fortran@gcc.gnu.org>
>> wrote:
>> 
>> Hello world,
>> 
>> this patch fixes Fortran's handling of common subexpression elimination
>> across ieee_set_rouding_mode calls.  It does so using a rather big
>> hammer, by issuing a memory barrier to force reload from memory
>> (and thus a recomputation).
>> 
>> This is a rather big hammer, so if there are more elegant ways
>> to fix it, I am very much open to suggestions.
>> 
>> If PR 34678 is fixed, then this solution can also be applied here.
>> 
>> OK for trunk?  How do you feel about a backport?
>> 
>> Best regards
>> 
>>        Thomas
>> 
>> Add memory barrier for calls to ieee_set_rounding_mode.
>> 
>> gcc/fortran/ChangeLog:
>> 
>>         PR fortran/108329
>>         * trans-expr.cc (trans_memory_barrier): New functions.
>>         (gfc_conv_procedure_call): Insert memory barrier for
>>         ieee_set_rounding_mode.
>> 
>> gcc/testsuite/ChangeLog:
>> 
>>         PR fortran/108329
>>         * gfortran.dg/rounding_4.f90: New test.
> 
> 
> 
> -- 
> "If you can't explain it simply, you don't understand it well enough" -
> Albert Einstein

Reply via email to