From bd0c543192682ffe6ab86d73aea943a5e71b7baa Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Tue, 16 Nov 2021 14:22:28 +0300 Subject: [PATCH] Disable fgMorphCastedBitwiseOp opt for floats (#61657) --- src/coreclr/jit/morph.cpp | 3 ++- .../JitBlue/Runtime_61629/Runtime_61629.cs | 17 +++++++++++++++++ .../JitBlue/Runtime_61629/Runtime_61629.csproj | 9 +++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_61629/Runtime_61629.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_61629/Runtime_61629.csproj diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 34205fdd203ed..4c18c7f918822 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -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 index 0000000000000..a14b10b0657cd --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_61629/Runtime_61629.cs @@ -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 index 0000000000000..f492aeac9d056 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_61629/Runtime_61629.csproj @@ -0,0 +1,9 @@ + + + Exe + True + + + + + \ No newline at end of file