Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
a74nh opened this issue May 30, 2025 · 2 comments · May be fixed by #116144
Open

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

a74nh opened this issue May 30, 2025 · 2 comments · May be fixed by #116144
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI arm-sve Work related to arm64 SVE/SVE2 support
Milestone

Comments

@a74nh
Copy link
Contributor

a74nh commented May 30, 2025

    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), 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

@a74nh
Copy link
Contributor Author

a74nh commented May 30, 2025

Fix incoming....

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label May 30, 2025
@a74nh a74nh self-assigned this May 30, 2025
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 30, 2025
@a74nh a74nh added arm-sve Work related to arm64 SVE/SVE2 support area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI untriaged New issue has not been triaged by the area owner labels May 30, 2025
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

a74nh added a commit to a74nh/runtime that referenced this issue May 30, 2025
Fixes dotnet#116140

When an embedded SVE instrinsic is created, during lowering a conditional select is created to embed the operation. This required to ensure there is a mask for the embedded intrinsic to use.

Ensure that the embedding conditional select can only be removed if the embedded intrinsic is also removed.
@kunalspathak kunalspathak added this to the 10.0.0 milestone May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI arm-sve Work related to arm64 SVE/SVE2 support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants