[Bug tree-optimization/125706] [100,101]%[65,80] gives less than optimial range

apowenq at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jun 10 02:25:18 GMT 2026


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125706

--- Comment #2 from Shan Huang <apowenq at gmail dot com> ---
> GCC truck at O3:
> src:
>         xor     eax, eax
>         ret
> 
> Clang truck at O3:
> src:
>         movsx   eax, dl
>         movsx   esi, sil
>         mov     ecx, edi
>         cdq
>         idiv    esi
>         sar     edx, cl
>         mov     eax, edx
>         ret

Sorry, I accidentally swapped the outputs for LLVM and GCC in my original post.
Here is the correct mapping:

GCC truck at O3:
src:
        movsx   eax, dl
        movsx   esi, sil
        mov     ecx, edi
        cdq
        idiv    esi
        sar     edx, cl
        mov     eax, edx
        ret

Clang truck at O3:
src:
        xor     eax, eax
        ret


More information about the Gcc-bugs mailing list