dotnet/runtime

[JIT] Sub-optimal chained bool optimization

Open

#81.442 aperta il 31 gen 2023

Vedi su GitHub
 (4 commenti) (0 reazioni) (0 assegnatari)C# (5445 fork)batch import
area-CodeGen-coreclrhelp wantedtenet-performance

Metriche repository

Star
 (17.886 star)
Metriche merge PR
 (Merge medio 12g 11h) (661 PR mergiate in 30 g)

Descrizione

        bool Test_Bool(bool u, bool v, bool w)
        {
            return u & v & w | u | v | w | u & v & w | u | v | w &
                   u & v & w | u | v | w | u & v & w | u | v | w &
                   u & v & w | u | v | w | u & v & w | u | v | w;
        }

X64 outputs:

G_M37833_IG02:
       mov      eax, edx
       and      eax, r8d
       and      eax, r9d
       mov      ecx, eax
       or       ecx, edx
       or       ecx, r8d
       or       ecx, r9d
       or       ecx, eax
       or       ecx, edx
       or       ecx, r8d
       mov      r10d, r9d
       and      r10d, edx
       and      r10d, r8d
       and      r10d, r9d
       or       ecx, r10d
       or       ecx, edx
       or       ecx, r8d
       or       ecx, r9d
       or       ecx, eax
       or       ecx, edx
       or       ecx, r8d
       or       ecx, r10d
       or       ecx, edx
       or       ecx, r8d
       or       ecx, r9d
       or       eax, ecx
       or       eax, edx
       or       eax, r8d
       or       eax, r9d
       movzx    rax, al
						;; size=79 bbWeight=1 PerfScore 7.50

G_M37833_IG03:
       ret      

but could output:

    or      edx, esi
    mov     eax, edx
    or      eax, edi
    movzx   rax, al
    ret

Given this is a contrived example, not sure what the overall impact would be if we did optimize this.

Guida contributor