JIT: Checked `emitExtractEvexPrefix` asserts on AVX10v1 FP16 instructions with no SIMD prefix (`vrndscalesh`, `vcmpph`, ...)

Đang mở Phù hợp với người mới
#138,181 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
65/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp, csharp
Lĩnh vực
compilers

Hướng nghiên cứu

Kiểm tra đang thất bại là assert trong emitExtractEvexPrefix trong src/coreclr/jit/emitxarch.cpp, dưới chú thích '// no simd prefix for EVEX2'. Issue đề xuất kiểm tra InstructionSet_AVX10v1 thay vì AVX10v2 ở đó, vì AVX10v2 bao hàm AVX10v1. Xác minh bằng cách build Checked JIT và encode vrndscalesh, ví dụ là 62 F3 7C 08 0A C6 02. Hoàn tất khi assert không còn kích hoạt cho các lệnh FP16 AVX10v1 và encoding không đổi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area-CodeGen-coreclr untriaged
Description

In Checked JIT builds, emitter::emitExtractEvexPrefix asserts when it encodes an AVX10v1 FP16 instruction whose opcode has no SIMD prefix (EVEX pp=00):

Assertion failed 'm_compiler->compIsaSupportedDebugOnly(InstructionSet_AVX10v2) ||
                  m_compiler->compIsaSupportedDebugOnly(InstructionSet_AVXVNNIINT) ||
                  m_compiler->compIsaSupportedDebugOnly(InstructionSet_AVXVNNIINT_V512)'
  src/coreclr/jit/emitxarch.cpp, emitExtractEvexPrefix  (// no simd prefix for EVEX2 - AVX10.2 and above)

The assert assumes that only AVX10v2 and AVX-VNNI-INT instructions use a 4-byte opcode with an empty prefix slot (PSSE38(0x00, ..)/PSSE3A(0x00, ..)). The AVX10v1 FP16 instructions added in #116230 also use that form:

vcmpph, vfpclassph, vfpclasssh, vgetmantph, vgetmantsh, vreduceph, vreducesh, vrndscaleph, vrndscalesh (all PSSE3A(0x00, ..), Encoding_EVEX only).

So whenever AVX10v1 is enabled and AVX10v2 is not, a Checked JIT asserts while emitting these instructions. EnableAVX10v2 defaults to 0, so this happens by default. Release builds skip the assert, and the encoding is correct: pp=00 is right for these NP opcodes. For example, vrndscalesh xmm0, xmm0, xmm6, 2 encodes as 62 F3 7C 08 0A C6 02.

Repro

SuperPMI replay with the Checked alt-JIT and RunAltJitCode=0. In that mode the alt-JIT enables all ISAs that have an Enable* default of 1, including AVX10v1. APX does not need to be enabled.

superpmi.exe -c 284033 -jitoption force AltJit=* -jitoption force AltJitNgen=* -jitoption force RunAltJitCode=0 ^
    artifacts\bin\coreclr\windows.x64.Checked\clrjit_win_x64_x64.dll ^
    libraries_tests_no_tiered_compilation.run.windows.x64.Release.mch

Collections for JIT-EE GUID c77c1a0f-c8c6-4a68-90db-4d8c1253c5ea (Windows x64 and Linux x64):

Collection Method context Method
libraries_tests_no_tiered_compilation 284033 System.Tests.HalfTests:RoundingFunctions (Half rounding uses vrndscalesh)
libraries_tests_no_tiered_compilation 220702 System.Numerics.Tensors.Tests.GenericFloatingPointNumberTensorPrimitivesTests1+<>c__D...`
libraries_tests 506942 (same assert)

With the native JIT, using the recorded ISA set (F16C only), these methods compile cleanly through vcvtph2ps/vcvtps2ph. Every APX superpmi-replay configuration hits these, because they all use RunAltJitCode=0. I expect a native Checked JIT on AVX10v1 hardware to hit them too, but I have not verified that on hardware.

Suggested fix

AVX10v2 requires AVX10v1 (corinfoinstructionset.h drops AVX10v2 when AVX10v1 is absent), so the assert can check AVX10v1 instead:

assert(m_compiler->compIsaSupportedDebugOnly(InstructionSet_AVX10v1) ||
       m_compiler->compIsaSupportedDebugOnly(InstructionSet_AVXVNNIINT) ||
       m_compiler->compIsaSupportedDebugOnly(InstructionSet_AVXVNNIINT_V512));
Related
  • Past this assert, the same instructions were overestimated by one byte: the empty prefix slot was not subtracted in emitGetAdjustedSize. This affects the VNNI-INT vpdp*uu* family as well. #137880 fixes that, because it makes estimate/encoding size mismatches assert.
  • Separate issue: the JitEmitUnitTestsSections=avx10v2 emitter unit tests hit assert(IsSimdVexOrEvexEncodableInstruction(ins) || IsApxExtendedEvexInstruction(ins)) in emitDispIns (IF_RWR_RWR_RRD) on vpdpwsud. It reproduces on the current branch without the #137880 changes.

[!NOTE]
This issue was drafted with GitHub Copilot.

Ngôn ngữ chính
C#
Star
18.5k
Fork
5.8k
Merge trung bình
2 ngày 18 giờ
Pull request đã merge (30 ngày)
588

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dotnet/runtime

Tất cả issue của dotnet/runtime

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.