Skip to content

JIT: (bug) an embedded broadcast of a runtime value hits a JIT assert when it is widened for masking #133552

Description

@EgorBo

Repro

using System;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;

class Program
{
    // The broadcast source is a runtime load, not a constant.
    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
    static unsafe Vector128<double> Test(Vector128<float> v, float* p,
                                         Vector128<double> a, Vector128<double> b, Vector128<double> f)
    {
        Vector128<float> anded = Sse.And(v, Vector128.Create(*p));
        return Vector128.ConditionalSelect(Vector128.Equals(a, b), anded.AsDouble(), f);
    }

    static unsafe void Main()
    {
        if (!Avx512F.VL.IsSupported)
            throw new PlatformNotSupportedException("AVX-512VL is required.");

        float x = 1.0f;
        var eq = Vector128.Create(1.0);

        Console.WriteLine(Test(Vector128.Create(1.0f), &x, eq, eq, Vector128.Create(9.0))
                          .AsUInt32().GetElement(0).ToString("X8"));
    }
}

Expected

3F800000

Actual

Assert failure(PID 46276 [0x0000b4c4], Thread: 112720 [0x1b850]): Assertion failed 'constNode->OperIs(GT_CNS_INT)' in 'Program:Test(System.Runtime.Intrinsics.Vector128`1[float],ptr,System.Runtime.Intrinsics.Vector128`1[double],System.Runtime.Intrinsics.Vector128`1[double],System.Runtime.Intrinsics.Vector128`1[double]):System.Runtime.Intrinsics.Vector128`1[double]' during 'Lowering nodeinfo' (IL size 35; hash 0xbc6a6a4e; FullOpts)

    File: C:\prj\runtime-main3\src\coreclr\jit\lowerxarch.cpp:10519

The same assert fires with Sse.Xor in place of Sse.And, and with the int/long forms. The
Vector256 and Vector512 shapes of the same pattern instead fail an adjacent assert
(tgtMaskSize == 2, lowerxarch.cpp:10509).

Platform

Windows x64 with AVX-512VL, local Checked build of dotnet/runtime main (ef97eb5).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions