dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.16k stars 4.72k forks source link

[JIT] Possible AltJit assertion when alt-jitting ARM64 #83119

Open TIHan opened 1 year ago

TIHan commented 1 year ago
        [MethodImpl(MethodImplOptions.NoInlining)]
        static void Test(Vector<int> increment)
        {
            while (increment != Vector<int>.Zero)
            {
                increment = increment + increment;
            }
        }

When using AltJit for ARM64, we get:

Assert failure(PID 64280 [0x0000fb18], Thread: 22980 [0x59c4]): Assertion failed 'genActualType(lclTyp) == genActualType(op1->gtType) || (genActualType(lclTyp) == TYP_I_IMPL && op1->IsLocalAddrExpr() != nullptr) || (genActualType(lclTyp) == TYP_I_IMPL && (op1->gtType == TYP_BYREF || op1->gtType == TYP_REF)) || (genActualType(op1->gtType) == TYP_I_IMPL && lclTyp == TYP_BYREF) || (varTypeIsFloating(lclTyp) && varTypeIsFloating(op1->TypeGet())) || ((genActualType(lclTyp) == TYP_BYREF) && genActualType(op1->TypeGet()) == TYP_REF) : Possibly bad IL with CEE_starg.s at offset 0009h (op1=simd16 op2=NULL stkDepth=0)' in 'test.Program:Test(System.Numerics.Vector`1[int])' during 'Importation' (IL size 25; hash 0xf8e36944; Tier0)

    File: C:\work\base\runtime\src\coreclr\jit\importer.cpp Line: 6904
    Image: C:\work\base\runtime\artifacts\bin\coreclr\windows.x64.Checked\CoreRun.exe

The assertion fails because the destination type is TYP_STRUCT instead of TYP_SIMD16.

This assertion does not happen when running this on ARM64 proper.

ghost commented 1 year ago

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

Issue Details
```csharp [MethodImpl(MethodImplOptions.NoInlining)] static void Test(Vector increment) { while (increment != Vector.Zero) { increment = increment + increment; } } ``` When using AltJit for ARM64, we get: ``` Assert failure(PID 64280 [0x0000fb18], Thread: 22980 [0x59c4]): Assertion failed 'genActualType(lclTyp) == genActualType(op1->gtType) || (genActualType(lclTyp) == TYP_I_IMPL && op1->IsLocalAddrExpr() != nullptr) || (genActualType(lclTyp) == TYP_I_IMPL && (op1->gtType == TYP_BYREF || op1->gtType == TYP_REF)) || (genActualType(op1->gtType) == TYP_I_IMPL && lclTyp == TYP_BYREF) || (varTypeIsFloating(lclTyp) && varTypeIsFloating(op1->TypeGet())) || ((genActualType(lclTyp) == TYP_BYREF) && genActualType(op1->TypeGet()) == TYP_REF) : Possibly bad IL with CEE_starg.s at offset 0009h (op1=simd16 op2=NULL stkDepth=0)' in 'test.Program:Test(System.Numerics.Vector`1[int])' during 'Importation' (IL size 25; hash 0xf8e36944; Tier0) File: C:\work\base\runtime\src\coreclr\jit\importer.cpp Line: 6904 Image: C:\work\base\runtime\artifacts\bin\coreclr\windows.x64.Checked\CoreRun.exe ``` The assertion fails because the destination type is `TYP_STRUCT` instead of `TYP_SIMD16`. This assertion does not happen when running this on ARM64 proper.
Author: TIHan
Assignees: -
Labels: `bug`, `area-CodeGen-coreclr`, `untriaged`
Milestone: -
EgorBo commented 1 year ago

I don't think it deserves a bug label, AltJit has tons of problems/asserts - just try to run any app with AltJit=* - we use it only as a quick way to validate arm64 codegen on x64. A better way to do that is to use crossgen with targetarch=arm64