Repository navigation
Closed
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone
Description
From fuzzlyn (from #118368, but happens in main without that PR).
// Generated by Fuzzlyn v3.3 on 2025-08-05 17:40:02
// Run on X86 Windows
// Seed: 9882026655407373813-vectort,vector128,vector256,x86aes,x86avx,x86avx2,x86avx512bw,x86avx512bwvl,x86avx512cd,x86avx512cdvl,x86avx512dq,x86avx512dqvl,x86avx512f,x86avx512fvl,x86bmi1,x86bmi2,x86fma,x86lzcnt,x86pclmulqdq,x86popcnt,x86sse,x86sse2,x86sse3,x86sse41,x86sse42,x86ssse3,x86x86base
// Reduced from 124.1 KiB to 1.5 KiB in 00:04:19
// Hits JIT assert for Release:
// Assertion failed 'isContainable || supportsRegOptional' in 'Program:M16(byte)' during 'Generate code' (IL size 72; hash 0x646d3daa; FullOpts)
//
// File: D:\a\_work\1\s\src\coreclr\jit\hwintrinsiccodegenxarch.cpp Line: 61
//
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
public class Program
{
public static IRuntime s_rt;
public static byte s_12;
public static bool s_18;
public static Vector128<long> s_30;
public static void Main()
{
CollectibleALC alc = new CollectibleALC();
System.Reflection.Assembly asm = alc.LoadFromAssemblyPath(System.Reflection.Assembly.GetExecutingAssembly().Location);
System.Reflection.MethodInfo mi = asm.GetType(typeof(Program).FullName).GetMethod(nameof(MainInner));
System.Type runtimeTy = asm.GetType(typeof(Runtime).FullName);
mi.Invoke(null, new object[] { System.Activator.CreateInstance(runtimeTy) });
}
public static void MainInner(IRuntime rt)
{
s_rt = rt;
M16(s_12);
}
public static void M16(byte arg0)
{
try
{
s_rt.WriteLine("c_66", 4294967195U);
}
catch (System.Exception)when (s_18)
{
}
arg0 %= arg0;
var vr2 = arg0 & 4294967295U;
var vr1 = Vector128.Create<long>(vr2);
s_30 = Sse2.ShiftLeftLogical128BitLane(vr1, 0);
}
}
public interface IRuntime
{
void WriteLine<T>(string site, T value);
}
public class Runtime : IRuntime
{
public void WriteLine<T>(string site, T value) => System.Console.WriteLine(value);
}
public class CollectibleALC : System.Runtime.Loader.AssemblyLoadContext
{
public CollectibleALC() : base(true)
{
}
}Run with TC=0:
// Assertion failed 'isContainable || supportsRegOptional' in 'Program:M16(byte)' during 'Generate code' (IL size 72; hash 0x646d3daa; FullOpts)
//
// File: D:\a\_work\1\s\src\coreclr\jit\hwintrinsiccodegenxarch.cpp Line: 61
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Activity
dotnet-policy-service commentedon Aug 6, 2025
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
MihuBot commentedon Aug 6, 2025
Possible related and/or duplicate issues:
AndyAyersMS commentedon Aug 6, 2025
Indeed this seems similar to #114654 but here it's LSRA that decides to mark the operand as contained.
During codegen, we have:
But the local is
ubyteso we don't have enough length to load it from memory.Seems like we need to spot this during lowering or long decomposition and fix the IR there?
AndyAyersMS commentedon Aug 7, 2025
FYI @dotnet/jit-contrib
AndyAyersMS commentedon Aug 7, 2025
@saucecontrol this looks similar to some issues you've fixed recently, any thoughts?
saucecontrol commentedon Aug 7, 2025
Yeah, this looks like it's from my changes. I'll give it a look.
saucecontrol commentedon Aug 8, 2025
I see the problem. Here, I'm marking the
LCL_VAR ubyteRegOptional and then containing the GT_LONG under theCreateScalarUnsafeHWIntrinsic:runtime/src/coreclr/jit/lowerxarch.cpp
Lines 9784 to 9792 in 96b3285
And then in codegen,
CreateScalarUnsafe(GT_LONG)will break down tomovd+pinsrd.runtime/src/coreclr/jit/hwintrinsiccodegenxarch.cpp
Lines 1913 to 1915 in 96b3285
Since the
LCL_VAR ubytewas marked RegOptional, LSRA is setting it to be contained, which I thought was ok, because the actual stack slot has to be 4 bytes anyway.With the assert removed, codegen looks like this:
So there are two possibilities:
LCL_VAR ubyte, given we can actually read 4 bytes there (and assuming the upper bytes are guaranteed to be zero) orLCL_VARof small type RegOptional in the first place.AndyAyersMS commentedon Aug 8, 2025
I believe you can only assume the storage is wide enough and properly zeroed for locals that are not
lvNormalizeOnLoad.saucecontrol commentedon Aug 8, 2025
Ok, thanks. I'll fix up that containment logic, then.