JIT: Skip Create(ToScalar(Dot(...))) transformation on mismatched types (#91089)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Fri, 25 Aug 2023 22:10:54 +0000 (15:10 -0700)
committerGitHub <noreply@github.com>
Fri, 25 Aug 2023 22:10:54 +0000 (15:10 -0700)
Fix #91062

Co-authored-by: Jakob Botsch Nielsen <jakob.botsch.nielsen@gmail.com>
src/coreclr/jit/morph.cpp
src/tests/JIT/Regression/JitBlue/Runtime_91062/Runtime_91062.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_91062/Runtime_91062.csproj [new file with mode: 0644]

index f29d6a5..52454b0 100644 (file)
@@ -10770,6 +10770,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 (file)
index 0000000..8886bd2
--- /dev/null
@@ -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<float> v1, Vector128<float> 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 (file)
index 0000000..de6d5e0
--- /dev/null
@@ -0,0 +1,8 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="$(MSBuildProjectName).cs" />
+  </ItemGroup>
+</Project>