dotnet/runtime

[JIT] Sub-optimal chained bool optimization

Open

#81,442 创建于 2023年1月31日

在 GitHub 查看
 (4 评论) (0 反应) (0 负责人)C# (5,445 fork)batch import
area-CodeGen-coreclrhelp wantedtenet-performance

仓库指标

Star
 (17,886 star)
PR 合并指标
 (平均合并 12天 11小时) (30 天内合并 661 个 PR)

描述

        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.

贡献者指南