bug report x86-64 code: je / jbe
Cecil Ward
cecil at cecilward.com
Sun Jun 18 02:55:32 UTC 2023
On Friday, 16 June 2023 at 13:12:06 UTC, Iain Buclaw wrote:
> On Wednesday, 14 June 2023 at 12:35:43 UTC, Cecil Ward wrote:
>> I have just noticed a bug in the latest release of GDC that
>> targets x86-64. For example GDC 12.3 and above versions too,
>> running on X86-64, targeting self. This was built with:
>> -O3 -frelease -march=alderlake
>>
>
> What leads you to believe that it is buggy?
>
>> Generated code is:
>>
>> je L1
>> jbe L1
>>
>
> What I see is the first instruction is going to relate to this
> condition.
>
>> if ( unlikely( p == 1 ) ) return x;
>
> Then the next instruction is the condition in the following
> for-loop.
>
>> for ( exp_ui_t i = p; i > 1; i >>= 1 )
>
> Redundant jump? Yes, arguably. Leads to wrong runtime? Doesn't
> look that way.
Completely agree with Iain, it’s not incorrect code, I wasn’t
intending to suggest that. I’d just say suboptimal, and not the
very best code generation possible.
More information about the D.gnu
mailing list