bug report x86-64 code: je / jbe

Iain Buclaw ibuclaw at gdcproject.org
Fri Jun 16 13:12:06 UTC 2023


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.


More information about the D.gnu mailing list