dotnet/runtime

[JIT] Sub-optimal chained bool optimization

Open

#81 442 ouverte le 31 janv. 2023

Voir sur GitHub
 (4 commentaires) (0 réactions) (0 assignés)C# (5 445 forks)batch import
area-CodeGen-coreclrhelp wantedtenet-performance

Métriques du dépôt

Stars
 (17 886 stars)
Métriques de merge PR
 (Merge moyen 12j 11h) (661 PRs mergées en 30 j)

Description

        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.

Guide contributeur