Disable fgMorphCastedBitwiseOp opt for floats (#61657)
authorEgor Bogatov <egorbo@gmail.com>
Tue, 16 Nov 2021 11:22:28 +0000 (14:22 +0300)
committerGitHub <noreply@github.com>
Tue, 16 Nov 2021 11:22:28 +0000 (14:22 +0300)
src/coreclr/jit/morph.cpp
src/tests/JIT/Regression/JitBlue/Runtime_61629/Runtime_61629.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_61629/Runtime_61629.csproj [new file with mode: 0644]

index 34205fd..4c18c7f 100644 (file)
@@ -10939,7 +10939,8 @@ GenTree* Compiler::fgMorphCastedBitwiseOp(GenTreeOp* tree)
         var_types toType     = op1->AsCast()->CastToType();
         bool      isUnsigned = op1->IsUnsigned();
 
-        if ((op2->CastFromType() != fromType) || (op2->CastToType() != toType) || (op2->IsUnsigned() != isUnsigned))
+        if (varTypeIsFloating(fromType) || (op2->CastFromType() != fromType) || (op2->CastToType() != toType) ||
+            (op2->IsUnsigned() != isUnsigned))
         {
             return nullptr;
         }
diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_61629/Runtime_61629.cs b/src/tests/JIT/Regression/JitBlue/Runtime_61629/Runtime_61629.cs
new file mode 100644 (file)
index 0000000..a14b10b
--- /dev/null
@@ -0,0 +1,17 @@
+// 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;
+
+public class Runtime_61629
+{
+    public static int Main() => 
+        Test(100, 200.0) + Test(Math.PI, Math.PI) - 72;
+
+    [MethodImpl(MethodImplOptions.NoInlining)]
+    static int Test(double a, double b)
+    {
+        return (int)a ^ (int)b >> 32;
+    }
+}
diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_61629/Runtime_61629.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_61629/Runtime_61629.csproj
new file mode 100644 (file)
index 0000000..f492aea
--- /dev/null
@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="$(MSBuildProjectName).cs" />
+  </ItemGroup>
+</Project>
\ No newline at end of file