KEMBAR78
Reevaluate HW intrinsic immediate const parameters after method containing HW intrinsics is inlined · Issue #11138 · dotnet/runtime · GitHub
Skip to content

Reevaluate HW intrinsic immediate const parameters after method containing HW intrinsics is inlined #11138

@4creators

Description

@4creators

The problem was described in https://github.com/dotnet/coreclr/issues/19888#issuecomment-423769762 and results from code quality question asked by @gdkchan https://github.com/dotnet/coreclr/issues/19888#issuecomment-423766095.

The code taken from OP illustrating problem is as follows:

private static void Test()
{
    Vector128<float> vec = Sse.SetZeroVector128();

    vec = VectorInsertSingle(vec, 0, 1.0f);
    vec = VectorInsertSingle(vec, 1, 1.5f);
    vec = VectorInsertSingle(vec, 2, 2.0f);
    vec = VectorInsertSingle(vec, 3, 2.5f);            
}

public static Vector128<float> VectorInsertSingle(Vector128<float> vector, byte index, float value)
{
    //Produces sub-optimal code (jump table fallback,
    //JIT doesn't notice that the value is constant after inline).
    return Sse41.Insert(vector, value, (byte)(index << 4));
}

Method VectorInsertSingle is inlined into method Test what should result in folding index into const value passed as a parameter. Currently Jit does not handle two constructs: (i) immediate HW intrinsic expansion after/during inlining, (ii) const expression folding. The second problem is covered by #11062 and this issue is created to track the first problem.

One of the possible solutions is covered by dotnet/csharplang#886 proposal.

category:cq
theme:hardware-intrinsics
skill-level:intermediate
cost:medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:3Work that is nice to havearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIin-prThere is an active PR which will close this issue when it is mergedoptimization

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions