From 73bffafa95247cef39d3f200d67be72c92e6e449 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Mon, 5 Aug 2024 15:38:10 -0700 Subject: [PATCH] Ensure side effects are preserved for Arm64 (#105963) --- src/coreclr/jit/gentree.cpp | 1 + .../JitBlue/Runtime_105818/Runtime_105818.cs | 44 +++++++++++++++++++ .../Runtime_105818/Runtime_105818.csproj | 8 ++++ 3 files changed, 53 insertions(+) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_105818/Runtime_105818.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_105818/Runtime_105818.csproj diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index dee719745f498..5c496b0e080de 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -31735,6 +31735,7 @@ GenTree* Compiler::gtFoldExprHWIntrinsic(GenTreeHWIntrinsic* tree) // op3 has side effects, this would require us to append a new statement // to ensure that it isn't lost, which isn't safe to do from the general // purpose handler here. We'll recognize this and mark it in VN instead + break; } // op3 has no side effects, so we can return op2 directly diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_105818/Runtime_105818.cs b/src/tests/JIT/Regression/JitBlue/Runtime_105818/Runtime_105818.cs new file mode 100644 index 0000000000000..3713482180885 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_105818/Runtime_105818.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.CompilerServices; +using System.Numerics; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.Arm; +using Xunit; + +// Generated by Fuzzlyn v2.2 on 2024-08-01 14:42:46 +// Run on Arm64 MacOS +// Seed: 17520120436908093806-vectort,vector64,vector128,armadvsimd,armadvsimdarm64,armaes,armarmbase,armarmbasearm64,armcrc32,armcrc32arm64,armdp,armrdm,armrdmarm64,armsha1,armsha256 +// Reduced from 35.4 KiB to 0.6 KiB in 00:00:19 +// Debug: Throws 'System.NullReferenceException' +// Release: Runs successfully + +public class Runtime_105818 +{ + private static Vector64 s_1; + + [Fact] + public static void TestEntryPoint() + { + if (AdvSimd.IsSupported) + { + Assert.Throws(() => M1()); + } + } + + private static void M1() + { + var vr2 = Vector64.Create(4294967295U); + var vr3 = Vector64.Create(0); + AdvSimd.BitwiseSelect(vr2, vr3, Vector64.CreateScalar(M2())); + System.Console.WriteLine(s_1); + } + + private static uint M2() + { + sbyte[] var0 = default(sbyte[]); + return (uint)var0[0]; + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_105818/Runtime_105818.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_105818/Runtime_105818.csproj new file mode 100644 index 0000000000000..de6d5e08882e8 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_105818/Runtime_105818.csproj @@ -0,0 +1,8 @@ + + + True + + + + +