From 6af853d7757e55a09fd9bc6dc1d6aa12c0b454f2 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 25 Jul 2024 21:31:39 -0700 Subject: [PATCH] Ensure constant evaluation of shifts on xarch broadcast the operand to the correct size (#105487) * Ensure constant evaluation of shifts on xarch broadcast the operand to the correct size * Ensure we don't try to execute AVX2 code on unsupported platforms --- src/coreclr/jit/gentree.cpp | 4 +++ .../JitBlue/Runtime_105465/Runtime_105465.cs | 26 +++++++++++++++++++ .../Runtime_105465/Runtime_105465.csproj | 8 ++++++ 3 files changed, 38 insertions(+) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_105465/Runtime_105465.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_105465/Runtime_105465.csproj diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index a140ecb935cb4..f24c4cae31ef2 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -30917,6 +30917,10 @@ GenTree* Compiler::gtFoldExprHWIntrinsic(GenTreeHWIntrinsic* tree) // Ensure we don't lose track the the amount is an overshift shiftAmount = -1; } + + // Ensure we broadcast to the right vector size + otherNode->gtType = retType; + otherNode->AsVecCon()->EvaluateBroadcastInPlace(simdBaseType, shiftAmount); } } diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_105465/Runtime_105465.cs b/src/tests/JIT/Regression/JitBlue/Runtime_105465/Runtime_105465.cs new file mode 100644 index 0000000000000..c12963036e164 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_105465/Runtime_105465.cs @@ -0,0 +1,26 @@ +// Generated by Fuzzlyn v1.7 on 2024-07-25 11:06:17 +// Run on X64 Windows +// Seed: 1535747306914661768-vectort,vector128,vector256,x86aes,x86avx,x86avx2,x86bmi1,x86bmi1x64,x86bmi2,x86bmi2x64,x86fma,x86lzcnt,x86lzcntx64,x86pclmulqdq,x86popcnt,x86popcntx64,x86sse,x86ssex64,x86sse2,x86sse2x64,x86sse3,x86sse41,x86sse41x64,x86sse42,x86sse42x64,x86ssse3,x86x86base +// Reduced from 95.3 KiB to 0.6 KiB in 00:00:29 +// Debug: Outputs <0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0> +// Release: Outputs <0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1> +using System; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; +using Xunit; + +public class Runtime_105465 +{ + [Fact] + public static void TestEntryPoint() + { + if (Avx2.IsSupported) + { + var vr2 = Vector256.Create(1); + var vr3 = Vector128.Create(1); + Vector256 vr4 = Avx2.ShiftLeftLogical(vr2, vr3); + Assert.Equal(Vector256.Zero, vr4); + } + } +} + diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_105465/Runtime_105465.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_105465/Runtime_105465.csproj new file mode 100644 index 0000000000000..de6d5e08882e8 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_105465/Runtime_105465.csproj @@ -0,0 +1,8 @@ + + + True + + + + +