From b619f758e33692d894aa389e56352d8556b09d5b Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Thu, 24 Aug 2023 16:52:55 +0200 Subject: [PATCH] JIT: Skip Create(ToScalar(Dot(...))) transformation on mismatched types Fix #91062 --- src/coreclr/jit/morph.cpp | 6 +++++ .../JitBlue/Runtime_91062/Runtime_91062.cs | 22 +++++++++++++++++++ .../Runtime_91062/Runtime_91062.csproj | 8 +++++++ 3 files changed, 36 insertions(+) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_91062/Runtime_91062.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_91062/Runtime_91062.csproj diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 87d0912b66445e..12f908f9d65457 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -10760,6 +10760,12 @@ GenTree* Compiler::fgOptimizeHWIntrinsic(GenTreeHWIntrinsic* node) break; } + // Must be working with the same types of vectors. + if (hwop1->TypeGet() != node->TypeGet()) + { + break; + } + if (toScalar != nullptr) { DEBUG_DESTROY_NODE(toScalar); diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_91062/Runtime_91062.cs b/src/tests/JIT/Regression/JitBlue/Runtime_91062/Runtime_91062.cs new file mode 100644 index 00000000000000..8886bd2044ab04 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_91062/Runtime_91062.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license.aa + +using System.Runtime.CompilerServices; +using System.Runtime.Intrinsics; +using System.Numerics; +using Xunit; + +public class Runtime_91062 +{ + [Fact] + public static void TestEntryPoint() + { + Foo(default, default); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static Vector2 Foo(Vector128 v1, Vector128 v2) + { + return Vector2.Lerp(default, default, Vector128.Dot(v1, v2)); + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_91062/Runtime_91062.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_91062/Runtime_91062.csproj new file mode 100644 index 00000000000000..de6d5e08882e86 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_91062/Runtime_91062.csproj @@ -0,0 +1,8 @@ + + + True + + + + +