From 7a5be3e58fa575415f35776803f6079f1b59abfa Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Tue, 5 Sep 2023 09:03:26 -0700 Subject: [PATCH 1/3] Ensure VN handles both forms of the xarch shift instructions for SIMD --- src/coreclr/jit/valuenum.cpp | 60 ++++ .../JitBlue/Runtime_91175/Runtime_91175.cs | 275 ++++++++++++++++++ .../Runtime_91175/Runtime_91175.csproj | 8 + 3 files changed, 343 insertions(+) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.csproj diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index e2af30d056cdd..728672582d57c 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -7432,6 +7432,26 @@ ValueNum ValueNumStore::EvalHWIntrinsicFunBinary(var_types type, case NI_AVX512BW_ShiftLeftLogical: #endif { +#ifdef TARGET_XARCH + if (TypeOfVN(arg1VN) == TYP_SIMD16) + { + // The xarch shift instructions support taking the shift amount as + // a simd16, in which case they take the shift amount from the lower + // 64-bits. + + uint64_t shiftAmount = GetConstantSimd16(arg1VN).u64[0]; + + if (genTypeSize(baseType) != 8) + { + arg1VN = VNForIntCon(static_cast(shiftAmount)); + } + else + { + arg1VN = VNForLongCon(static_cast(shiftAmount)); + } + } +#endif // TARGET_XARCH + return EvaluateBinarySimd(this, GT_LSH, /* scalar */ false, type, baseType, arg0VN, arg1VN); } @@ -7445,6 +7465,26 @@ ValueNum ValueNumStore::EvalHWIntrinsicFunBinary(var_types type, case NI_AVX512BW_ShiftRightArithmetic: #endif { +#ifdef TARGET_XARCH + if (TypeOfVN(arg1VN) == TYP_SIMD16) + { + // The xarch shift instructions support taking the shift amount as + // a simd16, in which case they take the shift amount from the lower + // 64-bits. + + uint64_t shiftAmount = GetConstantSimd16(arg1VN).u64[0]; + + if (genTypeSize(baseType) != 8) + { + arg1VN = VNForIntCon(static_cast(shiftAmount)); + } + else + { + arg1VN = VNForLongCon(static_cast(shiftAmount)); + } + } +#endif // TARGET_XARCH + return EvaluateBinarySimd(this, GT_RSH, /* scalar */ false, type, baseType, arg0VN, arg1VN); } @@ -7457,6 +7497,26 @@ ValueNum ValueNumStore::EvalHWIntrinsicFunBinary(var_types type, case NI_AVX512BW_ShiftRightLogical: #endif { +#ifdef TARGET_XARCH + if (TypeOfVN(arg1VN) == TYP_SIMD16) + { + // The xarch shift instructions support taking the shift amount as + // a simd16, in which case they take the shift amount from the lower + // 64-bits. + + uint64_t shiftAmount = GetConstantSimd16(arg1VN).u64[0]; + + if (genTypeSize(baseType) != 8) + { + arg1VN = VNForIntCon(static_cast(shiftAmount)); + } + else + { + arg1VN = VNForLongCon(static_cast(shiftAmount)); + } + } +#endif // TARGET_XARCH + return EvaluateBinarySimd(this, GT_RSZ, /* scalar */ false, type, baseType, arg0VN, arg1VN); } diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.cs b/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.cs new file mode 100644 index 0000000000000..c388f7408aecb --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.cs @@ -0,0 +1,275 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license.aa + +// Found by Antigen + + +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; +using System.Numerics; +using Xunit; + +public class TestClass +{ + public struct S1 + { + public Vector64 v64_uint_0; + } + + public struct S2 + { + public struct S2_D1_F4 + { + public short short_4; + } + public bool bool_1; + public S1 s1_2; + public S1 s1_3; + } + + public struct S3 + { + public struct S3_D1_F4 + { + public S1 s1_8; + } + public S1 s1_5; + public Vector4 v4_6; + public Vector256 v256_double_7; + } + + public struct S4 + { + public struct S4_D1_F2 + { + public struct S4_D2_F1 + { + public int int_10; + public S2 s2_11; + } + public struct S4_D2_F3 + { + public uint uint_13; + } + public ulong ulong_12; + } + public Vector128 v128_sbyte_9; + public Vector64 v64_sbyte_14; + public double double_15; + } + + public struct S5 + { + public struct S5_D1_F1 + { + public struct S5_D2_F3 + { + public sbyte sbyte_18; + public S2.S2_D1_F4 s2_s2_d1_f4_19; + public Vector256 v256_double_20; + } + public ushort ushort_16; + public S2 s2_17; + public uint uint_21; + } + } + + static bool s_bool_22 = false; + static byte s_byte_23 = 1; + static char s_char_24 = 'H'; + static decimal s_decimal_25 = -1.9444444444444444444444444444m; + static double s_double_26 = 2147483647; + static short s_short_27 = -2; + static int s_int_28 = 3; + static long s_long_29 = -1; + static sbyte s_sbyte_30 = 84; + static float s_float_31 = 1.0625f; + static string s_string_32 = "B9PA5V9"; + static ushort s_ushort_33 = 2; + static uint s_uint_34 = 2; + static ulong s_ulong_35 = 3; + static Vector64 s_v64_byte_36 = Vector64.Create(((byte)(3)), 5, 1, 1, 1, 5, 1, 2); + static Vector64 s_v64_sbyte_37 = Vector64.CreateScalar(((sbyte)(7))); + static Vector64 s_v64_short_38 = Vector64.Zero; + static Vector64 s_v64_ushort_39 = Vector64.Create(((ushort)(1))); + static Vector64 s_v64_int_40 = Vector64.Create(((int)(3))); + static Vector64 s_v64_uint_41 = Vector64.Create(((uint)(2)), 1); + static Vector64 s_v64_long_42 = Vector64.Create(((long)(-1))); + static Vector64 s_v64_ulong_43 = Vector64.Create(((ulong)(1))); + static Vector64 s_v64_float_44 = Vector64.Create(((float)(5.2105265f))); + static Vector64 s_v64_double_45 = Vector64.Create(((double)(84.08888888888889))); + static Vector128 s_v128_byte_46 = Vector128.Create(((byte)(1)), 1, 0, 84, 1, 3, 3, 5, 5, 2, 2, 3, 3, 2, 3, 0); + static Vector128 s_v128_sbyte_47 = Vector128.Create(((sbyte)(0)), 5, 0, 2, 6, -1, 5, -1, -2, 84, -2, 1, -1, -2, -2, 1); + static Vector128 s_v128_short_48 = Vector128.Create(((short)(1)), 3, 84, -2, -2, 1, 3, 5); + static Vector128 s_v128_ushort_49 = Vector128.Create(((ushort)(1))); + static Vector128 s_v128_int_50 = Vector128.Create(((int)(-2))); + static Vector128 s_v128_uint_51 = Vector128.AllBitsSet; + static Vector128 s_v128_long_52 = Vector128.Create(((long)(-1))); + static Vector128 s_v128_ulong_53 = Vector128.Zero; + static Vector128 s_v128_float_54 = Vector128.Create(((float)(-2f))); + static Vector128 s_v128_double_55 = Vector128.Create(((double)(-4.989010989010989))); + static Vector256 s_v256_byte_56 = Vector256.Create(((byte)(0))); + static Vector256 s_v256_sbyte_57 = Vector256.Create(((sbyte)(-1)), -2, -2, 84, 1, -2, -1, 84, 1, 0, -2, 5, 1, 5, 5, 1, -1, -1, 1, 5, -1, -1, 84, 84, -5, 1, -1, -2, -1, 84, 5, 1); + static Vector256 s_v256_short_58 = Vector256.Create(((short)(5))); + static Vector256 s_v256_ushort_59 = Vector256.CreateScalar(((ushort)(2))); + static Vector256 s_v256_int_60 = Vector256.CreateScalar(((int)(-2))); + static Vector256 s_v256_uint_61 = Vector256.Zero; + static Vector256 s_v256_long_62 = Vector256.CreateScalar(((long)(-2))); + static Vector256 s_v256_ulong_63 = Vector256.Create(((ulong)(5))); + static Vector256 s_v256_float_64 = Vector256.CreateScalar(((float)(-0.9594595f))); + static Vector256 s_v256_double_65 = Vector256.Zero; + static Vector2 s_v2_66 = new Vector2(((float)(1.030303f))); + static Vector3 s_v3_67 = new Vector3(((float)(5.071429f))); + static Vector4 s_v4_68 = Vector4.UnitW; + static S1 s_s1_69 = new S1(); + static S2.S2_D1_F4 s_s2_s2_d1_f4_70 = new S2.S2_D1_F4(); + static S2 s_s2_71 = new S2(); + static S3.S3_D1_F4 s_s3_s3_d1_f4_72 = new S3.S3_D1_F4(); + static S3 s_s3_73 = new S3(); + static S4.S4_D1_F2.S4_D2_F1 s_s4_s4_d1_f2_s4_d2_f1_74 = new S4.S4_D1_F2.S4_D2_F1(); + static S4.S4_D1_F2.S4_D2_F3 s_s4_s4_d1_f2_s4_d2_f3_75 = new S4.S4_D1_F2.S4_D2_F3(); + static S4.S4_D1_F2 s_s4_s4_d1_f2_76 = new S4.S4_D1_F2(); + static S4 s_s4_77 = new S4(); + static S5.S5_D1_F1.S5_D2_F3 s_s5_s5_d1_f1_s5_d2_f3_78 = new S5.S5_D1_F1.S5_D2_F3(); + static S5.S5_D1_F1 s_s5_s5_d1_f1_79 = new S5.S5_D1_F1(); + static S5 s_s5_80 = new S5(); + bool bool_81 = false; + byte byte_82 = 84; + char char_83 = 'M'; + decimal decimal_84 = 5m; + double double_85 = 1.0571428571428572; + short short_86 = 84; + int int_87 = 5; + long long_88 = 5; + sbyte sbyte_89 = -1; + float float_90 = 5f; + string string_91 = "MN5AH1GE"; + ushort ushort_92 = 5; + uint uint_93 = 1; + ulong ulong_94 = 84; + Vector64 v64_byte_95 = Vector64.Create(((byte)(1)), 3, 2, 84, 0, 5, 127, 2); + Vector64 v64_sbyte_96 = Vector64.CreateScalar(((sbyte)(-1))); + Vector64 v64_short_97 = Vector64.Create(((short)(-2))); + Vector64 v64_ushort_98 = Vector64.Create(((ushort)(5))); + Vector64 v64_int_99 = Vector64.Create(((int)(3)), -2); + Vector64 v64_uint_100 = Vector64.Create(((uint)(1)), 5); + Vector64 v64_long_101 = Vector64.Create(((long)(0))); + Vector64 v64_ulong_102 = Vector64.Create(((ulong)(5))); + Vector64 v64_float_103 = Vector64.Create(((float)(5.0833335f)), -4.9673915f); + Vector64 v64_double_104 = Vector64.Create(((double)(5.023809523809524))); + Vector128 v128_byte_105 = Vector128.Create(((byte)(0))); + Vector128 v128_sbyte_106 = Vector128.Create(((sbyte)(84)), 0, 3, -2, 5, -1, 5, -1, 5, 84, -1, 84, -5, 5, -1, 84); + Vector128 v128_short_107 = Vector128.CreateScalar(((short)(1))); + Vector128 v128_ushort_108 = Vector128.Create(((ushort)(5))); + Vector128 v128_int_109 = Vector128.Create(((int)(1)), -2, 5, -2); + Vector128 v128_uint_110 = Vector128.Create(((uint)(5))); + Vector128 v128_long_111 = Vector128.CreateScalar(((long)(-2))); + Vector128 v128_ulong_112 = Vector128.AllBitsSet; + Vector128 v128_float_113 = Vector128.AllBitsSet; + Vector128 v128_double_114 = Vector128.Create(((double)(1))); + Vector256 v256_byte_115 = Vector256.AllBitsSet; + Vector256 v256_sbyte_116 = Vector256.Create(((sbyte)(5))); + Vector256 v256_short_117 = Vector256.Create(((short)(-1))); + Vector256 v256_ushort_118 = Vector256.CreateScalar(((ushort)(0))); + Vector256 v256_int_119 = Vector256.Create(((int)(84))); + Vector256 v256_uint_120 = Vector256.Create(((uint)(5))); + Vector256 v256_long_121 = Vector256.CreateScalar(((long)(-2))); + Vector256 v256_ulong_122 = Vector256.AllBitsSet; + Vector256 v256_float_123 = Vector256.Create(((float)(1.0337079f))); + Vector256 v256_double_124 = Vector256.Create(((double)(1.0701754385964912))); + Vector2 v2_125 = new Vector2(((float)(-1.925926f))); + Vector3 v3_126 = new Vector3(((float)(3.0666666f))); + Vector4 v4_127 = new Vector4(((float)(1.0444444f))); + S1 s1_128 = new S1(); + S2.S2_D1_F4 s2_s2_d1_f4_129 = new S2.S2_D1_F4(); + S2 s2_130 = new S2(); + S3.S3_D1_F4 s3_s3_d1_f4_131 = new S3.S3_D1_F4(); + S3 s3_132 = new S3(); + S4.S4_D1_F2.S4_D2_F1 s4_s4_d1_f2_s4_d2_f1_133 = new S4.S4_D1_F2.S4_D2_F1(); + S4.S4_D1_F2.S4_D2_F3 s4_s4_d1_f2_s4_d2_f3_134 = new S4.S4_D1_F2.S4_D2_F3(); + S4.S4_D1_F2 s4_s4_d1_f2_135 = new S4.S4_D1_F2(); + S4 s4_136 = new S4(); + S5.S5_D1_F1.S5_D2_F3 s5_s5_d1_f1_s5_d2_f3_137 = new S5.S5_D1_F1.S5_D2_F3(); + S5.S5_D1_F1 s5_s5_d1_f1_138 = new S5.S5_D1_F1(); + S5 s5_139 = new S5(); + static int s_loopInvariant = 8; + private static List toPrint = new List(); + + private S1 Method1(S5 p_s5_140, S2 p_s2_141, byte p_byte_142, out S4.S4_D1_F2.S4_D2_F3 p_s4_s4_d1_f2_s4_d2_f3_143, ref S4.S4_D1_F2.S4_D2_F3 p_s4_s4_d1_f2_s4_d2_f3_144, ref S3 p_s3_145, S4 p_s4_146) + { + unchecked + { + long long_154 = 84; + p_s4_s4_d1_f2_s4_d2_f3_143 = s_s4_s4_d1_f2_s4_d2_f3_75; + int __loopvar31 = s_loopInvariant - 10, __loopSecondaryVar31_0 = s_loopInvariant - 3; + for (;;) + { + if (__loopvar31 >= s_loopInvariant) + break; + switch (((long)(long_88 & long_154))) + { + case 84: + { + break; + } + case -1: + { + break; + } + case -2: + { + try + { + } + finally + { + s_bool_22 = Avx.TestNotZAndNotC(((Vector256)(((Vector256)(v256_int_119 += ((Vector256)(v256_int_119 - s_v256_int_60)))) - ((Vector256)(s_v256_int_60 *= ((Vector256)(s_v256_int_60 - Vector256.Zero)))))), ((Vector256)(((Vector256)(Vector256.AsInt32(s_v256_ushort_59) - ((Vector256)(v256_int_119 *= v256_int_119)))) - Avx2.ShiftRightArithmetic(Vector256.AllBitsSet, Vector128.AllBitsSet)))); + } + break; + } + default: + { + break; + } + } + + // Added the following line so we don't loop infinitely + __loopvar31++; + } + return s1_128; + } + } + + private void Method0() + { + unchecked + { + byte byte_229 = 0; + S1 s1_242 = new S1(); + S2 s2_246 = new S2(); + S4.S4_D1_F2.S4_D2_F3 s4_s4_d1_f2_s4_d2_f3_254 = new S4.S4_D1_F2.S4_D2_F3(); + S4.S4_D1_F2.S4_D2_F3 s4_s4_d1_f2_s4_d2_f3_255 = s4_s4_d1_f2_s4_d2_f3_254; + S4 s4_257 = new S4(); + S4 s4_258 = s4_257; + S5 s5_263 = new S5(); + S5 s5_264 = s5_263; + s1_242 = Method1(s5_264, s2_246, ((byte)(byte_229 | ((byte)(((byte)(s_byte_23 + s_byte_23)) + ((byte)(byte_229 ^ s_byte_23)))))), out s4_s4_d1_f2_s4_d2_f3_134, ref s4_s4_d1_f2_s4_d2_f3_255, ref s_s3_73, s4_258); + return; + } + } + + [Fact] + public static void TestEntryPoint() + { + new TestClass().Method0(); + } +} +/* + +Assert failure(PID 1312 [0x00000520], Thread: 31184 [0x79d0]): Assertion failed '!varTypeIsSIMD(vns->TypeOfVN(argVN))' in 'TestClass:Method1(TestClass+S5,TestClass+S2,ubyte,byref,byref,byref,TestClass+S4):TestClass+S1:this' during 'Do value numbering' (IL size 224; hash 0xf238d379; Tier1-OSR) + File: D:\git\runtime\src\coreclr\jit\valuenum.cpp Line: 6668 + Image: D:\git\runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe +*/ diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.csproj new file mode 100644 index 0000000000000..de6d5e08882e8 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.csproj @@ -0,0 +1,8 @@ + + + True + + + + + From 5ef6d70e5ec2fe39035c01712982df487b31c240 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Tue, 5 Sep 2023 09:16:53 -0700 Subject: [PATCH 2/3] Simplify the testcase --- .../JitBlue/Runtime_91175/Runtime_91175.cs | 262 +----------------- 1 file changed, 3 insertions(+), 259 deletions(-) diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.cs b/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.cs index c388f7408aecb..db4223227b6af 100644 --- a/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.cs +++ b/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.cs @@ -1,275 +1,19 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license.aa -// Found by Antigen - - -using System; -using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; -using System.Numerics; using Xunit; public class TestClass { - public struct S1 - { - public Vector64 v64_uint_0; - } - - public struct S2 - { - public struct S2_D1_F4 - { - public short short_4; - } - public bool bool_1; - public S1 s1_2; - public S1 s1_3; - } - - public struct S3 - { - public struct S3_D1_F4 - { - public S1 s1_8; - } - public S1 s1_5; - public Vector4 v4_6; - public Vector256 v256_double_7; - } - - public struct S4 - { - public struct S4_D1_F2 - { - public struct S4_D2_F1 - { - public int int_10; - public S2 s2_11; - } - public struct S4_D2_F3 - { - public uint uint_13; - } - public ulong ulong_12; - } - public Vector128 v128_sbyte_9; - public Vector64 v64_sbyte_14; - public double double_15; - } - - public struct S5 - { - public struct S5_D1_F1 - { - public struct S5_D2_F3 - { - public sbyte sbyte_18; - public S2.S2_D1_F4 s2_s2_d1_f4_19; - public Vector256 v256_double_20; - } - public ushort ushort_16; - public S2 s2_17; - public uint uint_21; - } - } - - static bool s_bool_22 = false; - static byte s_byte_23 = 1; - static char s_char_24 = 'H'; - static decimal s_decimal_25 = -1.9444444444444444444444444444m; - static double s_double_26 = 2147483647; - static short s_short_27 = -2; - static int s_int_28 = 3; - static long s_long_29 = -1; - static sbyte s_sbyte_30 = 84; - static float s_float_31 = 1.0625f; - static string s_string_32 = "B9PA5V9"; - static ushort s_ushort_33 = 2; - static uint s_uint_34 = 2; - static ulong s_ulong_35 = 3; - static Vector64 s_v64_byte_36 = Vector64.Create(((byte)(3)), 5, 1, 1, 1, 5, 1, 2); - static Vector64 s_v64_sbyte_37 = Vector64.CreateScalar(((sbyte)(7))); - static Vector64 s_v64_short_38 = Vector64.Zero; - static Vector64 s_v64_ushort_39 = Vector64.Create(((ushort)(1))); - static Vector64 s_v64_int_40 = Vector64.Create(((int)(3))); - static Vector64 s_v64_uint_41 = Vector64.Create(((uint)(2)), 1); - static Vector64 s_v64_long_42 = Vector64.Create(((long)(-1))); - static Vector64 s_v64_ulong_43 = Vector64.Create(((ulong)(1))); - static Vector64 s_v64_float_44 = Vector64.Create(((float)(5.2105265f))); - static Vector64 s_v64_double_45 = Vector64.Create(((double)(84.08888888888889))); - static Vector128 s_v128_byte_46 = Vector128.Create(((byte)(1)), 1, 0, 84, 1, 3, 3, 5, 5, 2, 2, 3, 3, 2, 3, 0); - static Vector128 s_v128_sbyte_47 = Vector128.Create(((sbyte)(0)), 5, 0, 2, 6, -1, 5, -1, -2, 84, -2, 1, -1, -2, -2, 1); - static Vector128 s_v128_short_48 = Vector128.Create(((short)(1)), 3, 84, -2, -2, 1, 3, 5); - static Vector128 s_v128_ushort_49 = Vector128.Create(((ushort)(1))); - static Vector128 s_v128_int_50 = Vector128.Create(((int)(-2))); - static Vector128 s_v128_uint_51 = Vector128.AllBitsSet; - static Vector128 s_v128_long_52 = Vector128.Create(((long)(-1))); - static Vector128 s_v128_ulong_53 = Vector128.Zero; - static Vector128 s_v128_float_54 = Vector128.Create(((float)(-2f))); - static Vector128 s_v128_double_55 = Vector128.Create(((double)(-4.989010989010989))); - static Vector256 s_v256_byte_56 = Vector256.Create(((byte)(0))); - static Vector256 s_v256_sbyte_57 = Vector256.Create(((sbyte)(-1)), -2, -2, 84, 1, -2, -1, 84, 1, 0, -2, 5, 1, 5, 5, 1, -1, -1, 1, 5, -1, -1, 84, 84, -5, 1, -1, -2, -1, 84, 5, 1); - static Vector256 s_v256_short_58 = Vector256.Create(((short)(5))); - static Vector256 s_v256_ushort_59 = Vector256.CreateScalar(((ushort)(2))); - static Vector256 s_v256_int_60 = Vector256.CreateScalar(((int)(-2))); - static Vector256 s_v256_uint_61 = Vector256.Zero; - static Vector256 s_v256_long_62 = Vector256.CreateScalar(((long)(-2))); - static Vector256 s_v256_ulong_63 = Vector256.Create(((ulong)(5))); - static Vector256 s_v256_float_64 = Vector256.CreateScalar(((float)(-0.9594595f))); - static Vector256 s_v256_double_65 = Vector256.Zero; - static Vector2 s_v2_66 = new Vector2(((float)(1.030303f))); - static Vector3 s_v3_67 = new Vector3(((float)(5.071429f))); - static Vector4 s_v4_68 = Vector4.UnitW; - static S1 s_s1_69 = new S1(); - static S2.S2_D1_F4 s_s2_s2_d1_f4_70 = new S2.S2_D1_F4(); - static S2 s_s2_71 = new S2(); - static S3.S3_D1_F4 s_s3_s3_d1_f4_72 = new S3.S3_D1_F4(); - static S3 s_s3_73 = new S3(); - static S4.S4_D1_F2.S4_D2_F1 s_s4_s4_d1_f2_s4_d2_f1_74 = new S4.S4_D1_F2.S4_D2_F1(); - static S4.S4_D1_F2.S4_D2_F3 s_s4_s4_d1_f2_s4_d2_f3_75 = new S4.S4_D1_F2.S4_D2_F3(); - static S4.S4_D1_F2 s_s4_s4_d1_f2_76 = new S4.S4_D1_F2(); - static S4 s_s4_77 = new S4(); - static S5.S5_D1_F1.S5_D2_F3 s_s5_s5_d1_f1_s5_d2_f3_78 = new S5.S5_D1_F1.S5_D2_F3(); - static S5.S5_D1_F1 s_s5_s5_d1_f1_79 = new S5.S5_D1_F1(); - static S5 s_s5_80 = new S5(); - bool bool_81 = false; - byte byte_82 = 84; - char char_83 = 'M'; - decimal decimal_84 = 5m; - double double_85 = 1.0571428571428572; - short short_86 = 84; - int int_87 = 5; - long long_88 = 5; - sbyte sbyte_89 = -1; - float float_90 = 5f; - string string_91 = "MN5AH1GE"; - ushort ushort_92 = 5; - uint uint_93 = 1; - ulong ulong_94 = 84; - Vector64 v64_byte_95 = Vector64.Create(((byte)(1)), 3, 2, 84, 0, 5, 127, 2); - Vector64 v64_sbyte_96 = Vector64.CreateScalar(((sbyte)(-1))); - Vector64 v64_short_97 = Vector64.Create(((short)(-2))); - Vector64 v64_ushort_98 = Vector64.Create(((ushort)(5))); - Vector64 v64_int_99 = Vector64.Create(((int)(3)), -2); - Vector64 v64_uint_100 = Vector64.Create(((uint)(1)), 5); - Vector64 v64_long_101 = Vector64.Create(((long)(0))); - Vector64 v64_ulong_102 = Vector64.Create(((ulong)(5))); - Vector64 v64_float_103 = Vector64.Create(((float)(5.0833335f)), -4.9673915f); - Vector64 v64_double_104 = Vector64.Create(((double)(5.023809523809524))); - Vector128 v128_byte_105 = Vector128.Create(((byte)(0))); - Vector128 v128_sbyte_106 = Vector128.Create(((sbyte)(84)), 0, 3, -2, 5, -1, 5, -1, 5, 84, -1, 84, -5, 5, -1, 84); - Vector128 v128_short_107 = Vector128.CreateScalar(((short)(1))); - Vector128 v128_ushort_108 = Vector128.Create(((ushort)(5))); - Vector128 v128_int_109 = Vector128.Create(((int)(1)), -2, 5, -2); - Vector128 v128_uint_110 = Vector128.Create(((uint)(5))); - Vector128 v128_long_111 = Vector128.CreateScalar(((long)(-2))); - Vector128 v128_ulong_112 = Vector128.AllBitsSet; - Vector128 v128_float_113 = Vector128.AllBitsSet; - Vector128 v128_double_114 = Vector128.Create(((double)(1))); - Vector256 v256_byte_115 = Vector256.AllBitsSet; - Vector256 v256_sbyte_116 = Vector256.Create(((sbyte)(5))); - Vector256 v256_short_117 = Vector256.Create(((short)(-1))); - Vector256 v256_ushort_118 = Vector256.CreateScalar(((ushort)(0))); - Vector256 v256_int_119 = Vector256.Create(((int)(84))); - Vector256 v256_uint_120 = Vector256.Create(((uint)(5))); - Vector256 v256_long_121 = Vector256.CreateScalar(((long)(-2))); - Vector256 v256_ulong_122 = Vector256.AllBitsSet; - Vector256 v256_float_123 = Vector256.Create(((float)(1.0337079f))); - Vector256 v256_double_124 = Vector256.Create(((double)(1.0701754385964912))); - Vector2 v2_125 = new Vector2(((float)(-1.925926f))); - Vector3 v3_126 = new Vector3(((float)(3.0666666f))); - Vector4 v4_127 = new Vector4(((float)(1.0444444f))); - S1 s1_128 = new S1(); - S2.S2_D1_F4 s2_s2_d1_f4_129 = new S2.S2_D1_F4(); - S2 s2_130 = new S2(); - S3.S3_D1_F4 s3_s3_d1_f4_131 = new S3.S3_D1_F4(); - S3 s3_132 = new S3(); - S4.S4_D1_F2.S4_D2_F1 s4_s4_d1_f2_s4_d2_f1_133 = new S4.S4_D1_F2.S4_D2_F1(); - S4.S4_D1_F2.S4_D2_F3 s4_s4_d1_f2_s4_d2_f3_134 = new S4.S4_D1_F2.S4_D2_F3(); - S4.S4_D1_F2 s4_s4_d1_f2_135 = new S4.S4_D1_F2(); - S4 s4_136 = new S4(); - S5.S5_D1_F1.S5_D2_F3 s5_s5_d1_f1_s5_d2_f3_137 = new S5.S5_D1_F1.S5_D2_F3(); - S5.S5_D1_F1 s5_s5_d1_f1_138 = new S5.S5_D1_F1(); - S5 s5_139 = new S5(); - static int s_loopInvariant = 8; - private static List toPrint = new List(); - - private S1 Method1(S5 p_s5_140, S2 p_s2_141, byte p_byte_142, out S4.S4_D1_F2.S4_D2_F3 p_s4_s4_d1_f2_s4_d2_f3_143, ref S4.S4_D1_F2.S4_D2_F3 p_s4_s4_d1_f2_s4_d2_f3_144, ref S3 p_s3_145, S4 p_s4_146) - { - unchecked - { - long long_154 = 84; - p_s4_s4_d1_f2_s4_d2_f3_143 = s_s4_s4_d1_f2_s4_d2_f3_75; - int __loopvar31 = s_loopInvariant - 10, __loopSecondaryVar31_0 = s_loopInvariant - 3; - for (;;) - { - if (__loopvar31 >= s_loopInvariant) - break; - switch (((long)(long_88 & long_154))) - { - case 84: - { - break; - } - case -1: - { - break; - } - case -2: - { - try - { - } - finally - { - s_bool_22 = Avx.TestNotZAndNotC(((Vector256)(((Vector256)(v256_int_119 += ((Vector256)(v256_int_119 - s_v256_int_60)))) - ((Vector256)(s_v256_int_60 *= ((Vector256)(s_v256_int_60 - Vector256.Zero)))))), ((Vector256)(((Vector256)(Vector256.AsInt32(s_v256_ushort_59) - ((Vector256)(v256_int_119 *= v256_int_119)))) - Avx2.ShiftRightArithmetic(Vector256.AllBitsSet, Vector128.AllBitsSet)))); - } - break; - } - default: - { - break; - } - } - - // Added the following line so we don't loop infinitely - __loopvar31++; - } - return s1_128; - } - } - - private void Method0() - { - unchecked - { - byte byte_229 = 0; - S1 s1_242 = new S1(); - S2 s2_246 = new S2(); - S4.S4_D1_F2.S4_D2_F3 s4_s4_d1_f2_s4_d2_f3_254 = new S4.S4_D1_F2.S4_D2_F3(); - S4.S4_D1_F2.S4_D2_F3 s4_s4_d1_f2_s4_d2_f3_255 = s4_s4_d1_f2_s4_d2_f3_254; - S4 s4_257 = new S4(); - S4 s4_258 = s4_257; - S5 s5_263 = new S5(); - S5 s5_264 = s5_263; - s1_242 = Method1(s5_264, s2_246, ((byte)(byte_229 | ((byte)(((byte)(s_byte_23 + s_byte_23)) + ((byte)(byte_229 ^ s_byte_23)))))), out s4_s4_d1_f2_s4_d2_f3_134, ref s4_s4_d1_f2_s4_d2_f3_255, ref s_s3_73, s4_258); - return; - } - } + [MethodImpl(MethodImplOptions.NoInlining)] + public static Vector256 Method0() => Avx2.ShiftRightArithmetic(Vector256.AllBitsSet, Vector128.AllBitsSet); [Fact] public static void TestEntryPoint() { - new TestClass().Method0(); + _ = Method0(); } } -/* - -Assert failure(PID 1312 [0x00000520], Thread: 31184 [0x79d0]): Assertion failed '!varTypeIsSIMD(vns->TypeOfVN(argVN))' in 'TestClass:Method1(TestClass+S5,TestClass+S2,ubyte,byref,byref,byref,TestClass+S4):TestClass+S1:this' during 'Do value numbering' (IL size 224; hash 0xf238d379; Tier1-OSR) - File: D:\git\runtime\src\coreclr\jit\valuenum.cpp Line: 6668 - Image: D:\git\runtime\artifacts\tests\coreclr\windows.x64.Checked\tests\Core_Root\CoreRun.exe -*/ From 64d4b40430e19721b12732bc2c6ba69e8c0e8bb8 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Tue, 5 Sep 2023 12:52:57 -0700 Subject: [PATCH 3/3] Ensure the test correctly checks for isa support --- .../JitBlue/Runtime_91175/Runtime_91175.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.cs b/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.cs index db4223227b6af..6e1f8fe9fd525 100644 --- a/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.cs +++ b/src/tests/JIT/Regression/JitBlue/Runtime_91175/Runtime_91175.cs @@ -11,9 +11,20 @@ public class TestClass [MethodImpl(MethodImplOptions.NoInlining)] public static Vector256 Method0() => Avx2.ShiftRightArithmetic(Vector256.AllBitsSet, Vector128.AllBitsSet); + [MethodImpl(MethodImplOptions.NoInlining)] + public static Vector128 Method1() => Sse2.ShiftRightArithmetic(Vector128.AllBitsSet, Vector128.AllBitsSet); + [Fact] public static void TestEntryPoint() { - _ = Method0(); + if (Avx2.IsSupported) + { + _ = Method0(); + } + + if (Sse2.IsSupported) + { + _ = Method1(); + } } }