Skip to content

assert failed !IsDummyUse() for an OBJ under HWINTRINSIC. #39737

@sandreenko

Description

@sandreenko

Try to compile and run the following test (Windows x64, SSE41 supported, tiering disabled, checked Runtime):

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

class Runtime_39403
{
   
    public static int Main()
    {
        if (Sse41.IsSupported)
        {
            Vector128<int> left = Vector128.Create(1);
            Vector128<int> right = Vector128.Create(2);
            ref var rightRef = ref right;
            Vector128<int> mask = Vector128.Create(3);
            Sse41.BlendVariable(left, rightRef, mask);
        }
        return 100;
    }
}

it will fail with:

Assert failure(PID 97424 [0x00017c90], Thread: 121580 [0x1daec]): Assertion failed '!IsDummyUse()' in 'Runtime_39403:Main():int' during 'Rationalize IR' (IL size 48)

    File: D:\Sergey\git\runtime\src\coreclr\src\jit\lir.cpp Line: 109

That happens because when we delete the dead Sse41.BlendVariable we extract side effects from arguments and one of them is:

top level assign
Extracted side effects list...
N003 (  9,  6) [000024] ---XG-------              *  OBJ       simd16<System.Runtime.Intrinsics.Vector128`1[Int32]>
N002 (  3,  2) [000023] ------------              \--*  LCL_VAR   byref  V02 loc2

that we don't expect to see later.

There are a few things that could be fixed here:

  1. the local var in this example should be marked as lvStackByref, so OBJ can't throw and there is no side effect (however, we can change the test so it is necessary to keep the obj node);
  2. replace OBJ with null check when extract as a to side effect.

category:correctness
theme:intrinsics
skill-level:intermediate
cost:small

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions