• Two-off code in program that runs in about 0.25 seconds

    From Robert Prins@21:1/5 to All on Sun Apr 16 14:21:27 2023
    Current code, simplified:

    mov ecx, 10
    cdq
    div ecx
    cdq
    div ecx

    Equivalent faster, but longer code:

    imul eax, 0xcccd
    shr eax, 19
    imul eax, 0xcccd
    shr eax, 19

    And yes, as EAX is guaranteed to be small (<= 200) it is equivalent!

    Should I really care, or not? And what would a modern compiler generate?

    Robert
    --
    Robert AH Prins
    robert(a)prino(d)org
    The hitchhiking grandfather - https://prino.neocities.org/
    Some REXX code for use on z/OS - https://prino.neocities.org/zOS/zOS-Tools.html

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)