Skip to content

Arm64 SVE: Assert failure when TrueMask used in conditional select #116140

@a74nh

Description

@a74nh
    static unsafe void CndSelectEmbeddedOp3LoadTrueMask(int[] array, Vector<int> op1)
    {
        fixed (int* arr_ptr = array)
        {
            var result = Sve.ConditionalSelect(Sve.CreateTrueMaskInt32(), op1, Sve.LoadVectorNonFaulting(arr_ptr));
            Consume(result);
        }
    }
Assert failure(PID 1322427 [0x00142dbb], Thread: 1322427 [0x142dbb]): Assertion failed '!node->IsEmbMaskOp()' in 'EmbeddedLoads:CndSelectEmbeddedOp3LoadTrueMask(int[],System.Numerics.Vector`1[int])' during 'Generate code' (IL size 51; hash 0xedf2dbdb; FullOpts)

    File: /mnt/sdb/home/alahay01/dotnet/runtime_table/src/coreclr/jit/hwintrinsiccodegenarm64.cpp:1093
    Image: /mnt/sdb/home/alahay01/dotnet/runtime_table/artifacts/tests/coreclr/linux.arm64.Checked/Tests/Core_Root/corerun

This is because LIR optimises ConditionalSelect(True, x, EmbeddedConditionalSelect(True, Load(), 0)) to x. Later the EmbeddedConditionalSelect() is removed as unused. However, the Load() is kept because it's a load/store.
The Load() fails to codegen becuase it is not inside an EmbeddedConditionalSelect()

There are similar tests in HWIntrinsics, but they use Vector<int>.AllBitsSet instead of truemask, and so the optimisation in lowering never happens

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIarm-sveWork related to arm64 SVE/SVE2 supportin-prThere is an active PR which will close this issue when it is merged

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions