Repository navigation
Closed
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone
Description
Description
When running a Release build, performing a (ushort)(uint) cast on int and storing the result in a ushort* seems to write out 32 bits instead of 16 bits.
Reproduction Steps
- Clone repo https://github.com/TechPizzaDev/SoftwareRasterizer
- Checkout branch
net8-upgrade - Download Castle folder from https://github.com/rawrunprotected/rasterizer/tree/master/SoftwareRasterizer and put next to built SoftwareRasterizer.exe
- Run project in Release mode to see broken render (it works in Debug mode)
- Remove
BUGdefine (https://github.com/TechPizzaDev/SoftwareRasterizer/blob/318adc376bcdaee1b6c863dd9384871aed82897e/SoftwareRasterizer/Avx2Rasterizer.cs#L2) - Run project again to see correct render
Expected behavior
Actual behavior
Regression?
Regression in net8, worked on net7 and net6.
Known Workarounds
Rewriting the code seems like the only workaround. The project also works in Debug mode.
Configuration
.NET: 8.0.0-rc.1.23419.4
OS: Microsoft Windows 11 Home (10.0.22621 version 22621)
CPU: 11th Gen Intel(R) Core(TM) i3-1115G4 @ 3.00GHz
Arch: x64
Env variables
DOTNET_EnableAVX512F=0: Required since net8 seems to cause unexpected AccessViolationExceptions.
Other information
Sse41.MinHorizontal(Vector128<ushort>) returns a Vector128<ushort> where the first ushort element is the minimum value from the vector, and the second ushort element is the index of the min element within the vector.
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI


Activity
TechPizzaDev commentedon Sep 20, 2023
Disassembly of suspected code:
Seems as if 32 instead of 16 bits are moved, judging by that
word ptrtodword ptrdiff.correct jitdisasm.txt
bug jitdisasm.txt
AndyAyersMS commentedon Sep 20, 2023
Are you saying there are two problems?
TechPizzaDev commentedon Sep 20, 2023
I have not gotten to what causes access violations on AVX512, but
DOTNET_EnableAVX512=1with fixed code still AVs, so I am sure these are two different problems.AndyAyersMS commentedon Sep 20, 2023
@dotnet/jit-contrib FYI
JulieLeeMSFT commentedon Sep 20, 2023
@TIHan, PTAL.
TIHan commentedon Sep 20, 2023
Was actually just looking at it :) should be interesting
TIHan commentedon Sep 21, 2023
I can confirm that that the suspected disassembly is cause of the issue.
Looking at a dump of a similar example, we remove the
CAST int <- ushort <- int:However, it isn't clear if the CAST removal itself is the main issue. We may not be handling something correctly later. Such as, we are not respecting the
shortofSTOREINDin codegen.