dotnet/runtime

[JIT] Sub-optimal chained bool optimization

Open

#81.442 geöffnet am 31. Jan. 2023

Auf GitHub ansehen
 (4 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (5.445 Forks)batch import
area-CodeGen-coreclrhelp wantedtenet-performance

Repository-Metriken

Stars
 (17.886 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 12T 11h) (661 gemergte PRs in 30 T)

Beschreibung

        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.

Contributor Guide