Skip to content

Converting a Vector4 to a Vector3 using ref asserts #13635

@tannergooding

Description

@tannergooding

The following code under x86 Release mode:

static void Main(string[] args)
{
    Console.WriteLine($"Is64Bit: {Environment.Is64BitProcess}");
    var result = AsVector3(Vector4.One);
    Console.WriteLine(result);
}

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
public static Vector3 AsVector3(Vector4 value)
{
    return Unsafe.As<Vector4, Vector3>(ref value);
}

Fires the following assert:

Assert failure(PID 66636 [0x0001044c], Thread: 69336 [0x10ed8]): Assertion failed 'varDsc->lvType == TYP_SIMD12' in 'ConsoleApp10.Program:AsVector3(struct):struct' (IL size 13)

    File: C:\Users\tagoo\repos\coreclr_base\src\jit\compiler.h Line: 3385
    Image: C:\Users\tagoo\repos\coreclr_base\bin\tests\Windows_NT.x86.Debug\Tests\Core_Root\CoreRun.exe

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-x86area-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