dotnet/runtime

Implicit tail calls block folding of intrinsics in value numbering

Open

#52,280 建立於 2021年5月5日

在 GitHub 查看
 (1 留言) (0 反應) (1 負責人)C# (5,445 fork)batch import
Priority:3area-CodeGen-coreclrhelp wanted

倉庫指標

Star
 (17,886 star)
PR 合併指標
 (平均合併 12天 11小時) (30 天內合併 661 個 PR)

描述

Reproduction:

private static double NotFolded(double a)
{
    var b = 1.0d;
    if (a is 0)
        return 0;

    return Math.Cos(b);
}

Codegen, Windows x64:

G_M24041_IG01:
       vzeroupper 
G_M24041_IG02:
       vxorps   xmm1, xmm1
       vucomisd xmm0, xmm1
       jp       SHORT G_M24041_IG05
       jne      SHORT G_M24041_IG05
G_M24041_IG03:
       vxorps   xmm0, xmm0
G_M24041_IG04:
       ret      
G_M24041_IG05:
       vmovsd   xmm0, qword ptr [reloc @RWD00]
G_M24041_IG06:
       jmp      System.Math:Cos(double):double

Value numbering today supports folding some intrinsics implemented by user calls. However, that support is only for actual GT_INTRINSIC nodes. Tail calls to intrinsics implemented via user calls are imported as plain GT_CALLs, blocking the optimization.

Issue is for tracking purposes, I do not expect this to be a big problem in real-world scenarios.

category:cq theme:tail-call skill-level:beginner cost:small impact:small

貢獻者指南