[PATCH] Fortran: Cray pointer comparison wrongly optimized away [PR106692]

Harald Anlauf anlauf@gmx.de
Fri Jan 3 22:09:14 GMT 2025


Hi Jerry!

Am 03.01.25 um 05:21 schrieb Jerry D:
> On 1/2/25 12:04 PM, Harald Anlauf wrote:
>> Dear all,
>>
>> this patch addresses overeager optimization of Cray pointers when
>> used in comparisons.  Cray pointers are non-standard, and odd in a
>> sense that they were introduced before modern Fortran pointers.
>> Comparisons with e.g. a "NULL" pointer are actually comparisons
>> with integer zero etc., which means that while they are references
>> they can actually be "NULL" to mimic a disassociated pointer.
>> The only solution I could find was treating them locally as volatile
>> when used in a comparison.  If someone has a better solution, please
>> share!
>>
>> As this is a local solution, and a real-world legacy code using Cray
>> pointers would likely never use such a test in a vectorizable loop,
>> I expect negligible (performance and code-size) impact.
>>
>> Regtested on x86_64-pc-linux-gnu.  OK for mainline?
>>
>> This PR is marked as a regression (since gcc-7), is this OK for
>> a (limited?) backport?
>>
>> Thanks,
>> Harald
>>
>
> The hack is fairly isolated and simple. The problem is a quirk from the
> past. The only way to expose an issue is to get it into the real world
> and see if anyone notices a problem.

I do not have access to any code using Cray pointers beyond what is in
the testsuite.  They might get used in some SPEC benchmark, we'll see.

> OK for trunk and maybe 14.  If you think farther back, up to you.

Pushed to mainline as r15-6545 so far.

Thanks for the feedback!

Harald

> Jerry
>



More information about the Fortran mailing list