Repository navigation
Closed
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Description
On Windows x64:
// Found by Antigen
// Reduced from 30.05 KB to 2.35 KB.
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;
using System.Numerics;
public class TestClass
{
public struct S1
{
}
public struct S2
{
}
static Vector128<byte> s_v128_byte_17 = Vector128.Create((byte)74, 2, 1, 5, 1, 1, 74, 74, 2, 1, 1, 2, 5, 1, 74, 2);
static Vector512<int> s_v512_int_41 = Vector512.Create(5);
static Vector512<long> s_v512_long_43 = Vector512.CreateScalar((long)4);
static Vector512<double> s_v512_double_46 = Vector512.Create(4, -4.971830985915493, -0.9789473684210527, -1.956043956043956, 2, 74.25, 1.0533333333333332, 4.033898305084746);
static S1 s_s1_60 = new S1();
static S2 s_s2_61 = new S2();
float float_71 = -0.9876543f;
Vector128<double> v128_double_86 = Vector128.Create(-0.9791666666666666);
Vector512<ushort> v512_ushort_100 = Vector512.CreateScalar((ushort)74);
Vector512<int> v512_int_101 = Vector512<int>.Zero;
Vector512<long> v512_long_103 = Vector512.CreateScalar((long)5);
private static List<string> toPrint = new List<string>();
public Vector512<long> Method1(S1 p_s1_122, out float p_float_123, bool p_bool_124, out Vector512<int> p_v512_int_125, ref Vector512<ushort> p_v512_ushort_126, Vector128<byte> p_v128_byte_127, Vector128<double> p_v128_double_128, ref S2 p_s2_129)
{
unchecked
{
p_float_123 = 15+4;
p_v512_int_125 = v512_int_101 = Vector512<int>.AllBitsSet * s_v512_int_41+ v512_int_101 | v512_int_101| v512_int_101& Vector512.AsInt32(s_v512_double_46 ^ Vector512<double>.AllBitsSet);
return (15|4)* (s_v512_long_43 += 15*4* s_v512_long_43)^ v512_long_103 * s_v512_long_43+ (s_v512_long_43 += 15*4* s_v512_long_43);
}
}
public void Method0()
{
unchecked
{
v512_long_103 = Method1(s_s1_60, out float_71, 15==4, out v512_int_101, ref v512_ushort_100, s_v128_byte_17 -= Vector128<byte>.AllBitsSet & s_v128_byte_17 ^ s_v128_byte_17, v128_double_86 += v128_double_86 & v128_double_86, ref s_s2_61);
return;
}
}
public static void Main(string[] args)
{}
public static int Antigen()
{
new TestClass().Method0();
return string.Join(Environment.NewLine, toPrint).GetHashCode();
}
}
/*
Environment:
set DOTNET_JitStressProcedureSplitting=1
set DOTNET_TieredPGO_InstrumentedTierAlwaysOptimized=1
set DOTNET_JitRandomEdgeCounts=1
set DOTNET_JitCheckSynthesizedCounts=1
set DOTNET_TieredCompilation=0
set DOTNET_PreferredVectorBitWidth=512
set DOTNET_JitStressRegs=1
set DOTNET_JitThrowOnAssertionFailure=1
set DOTNET_LegacyExceptionHandling=1
Debug: 1335962276
Release: 0
JIT assert failed:
Assertion failed 'ins != INS_invalid' in 'TestClass:Method1(TestClass+S1,byref,ubyte,byref,byref,System.Runtime.Intrinsics.Vector128`1[ubyte],System.Runtime.Intrinsics.Vector128`1[double],byref):System.Runtime.Intrinsics.Vector512`1[long]:this' during 'Generate code' (IL size 189; hash 0x309db00f; FullOpts)
File: D:\a\_work\1\s\src\coreclr\jit\hwintrinsiccodegenxarch.cpp Line: 389
*/cc @dotnet/jit-contrib
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Activity
dotnet-policy-service commentedon Aug 15, 2024
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
AndyAyersMS commentedon Aug 15, 2024
I'll take a look.
AndyAyersMS commentedon Aug 15, 2024
Seems like it requires AVX512 ... also if it requires
DOTNET_JitStressProcedureSplitting=1then will move to 10.0.AndyAyersMS commentedon Aug 15, 2024
Only required config setting is
DOTNET_TieredCompilation=0. So possibly a 9.0 issue.AndyAyersMS commentedon Aug 15, 2024
we are trying to generate
NI_AVX512DQ_AndNotAndyAyersMS commentedon Aug 15, 2024
Just upstream we have
in source this is
and it seems like the
Vector512.AsInt32effect is perhaps lost. Lower coalesces these toAndNotas if simd base type was double (taken from theXor), and later we blow up looking for an instruction that can handle int.AndyAyersMS commentedon Aug 15, 2024
One possible fix is to pick up the
simdBaseTypefrom the survivingAndnode...@tannergooding is this too simplistic?
tannergooding commentedon Aug 15, 2024
AsInt32is a type of bitcast and is dropped as part of importation.There's a bit of a tradeoff here in how it impacts codegen and other downstream optimizations (like whether an embedded maski or embedded broadcast can be used).
I think for .NET 9 using the base type from
userIntrinis the simpler option and the least likely to cause issues. I'll log an issue tracking a "better" fix that takes into account the optimizations for "future".JIT: update simd base type when combining simd nodes for bitwise ops
JIT: update simd base type when combining simd nodes for bitwise ops
JIT: update simd base type when combining simd nodes for bitwise ops
JIT: update simd base type when combining simd nodes for bitwise ops (d…
JIT: update simd base type when combining simd nodes for bitwise ops (#…
JIT: update simd base type when combining simd nodes for bitwise ops (d…