From 9030b78f19b363da4ffcaa00d8ae4929b010fd48 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Thu, 10 Mar 2022 12:45:58 +0300 Subject: [PATCH] Fix implicit nullchecks for floats on arm64 (#66413) --- src/coreclr/jit/compiler.cpp | 2 +- .../JitBlue/Runtime_65942/Runtime_65942.cs | 29 ++++++++++++++++++++++ .../JitBlue/Runtime_65942/Runtime_65942.csproj | 10 ++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_65942/Runtime_65942.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_65942/Runtime_65942.csproj diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index 464933b..3271e9d 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -9755,7 +9755,7 @@ bool Compiler::lvaIsOSRLocal(unsigned varNum) // var_types Compiler::gtTypeForNullCheck(GenTree* tree) { - if (varTypeIsIntegral(tree)) + if (varTypeIsArithmetic(tree)) { #if defined(TARGET_XARCH) // Just an optimization for XARCH - smaller mov diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_65942/Runtime_65942.cs b/src/tests/JIT/Regression/JitBlue/Runtime_65942/Runtime_65942.cs new file mode 100644 index 0000000..1ffeb78 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_65942/Runtime_65942.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.CompilerServices; + +unsafe class Runtime_65942 +{ + [MethodImpl(MethodImplOptions.NoInlining)] + private static void Test1(double* a, int i) + { + double unused1 = a[i]; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static void Test2(float* a, int i) + { + float unused1 = a[i]; + } + + private static int Main() + { + double d = 0; + Test1(&d, 0); + + float f = 0; + Test2(&f, 0); + return 100; + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_65942/Runtime_65942.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_65942/Runtime_65942.csproj new file mode 100644 index 0000000..cf94135 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_65942/Runtime_65942.csproj @@ -0,0 +1,10 @@ + + + Exe + True + true + + + + + \ No newline at end of file -- 2.7.4