Skip to content

Commit

Permalink
Disable fgMorphCastedBitwiseOp opt for floats (#61657)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo committed Nov 16, 2021
1 parent c397327 commit bd0c543
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
17 changes: 17 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_61629/Runtime_61629.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>

0 comments on commit bd0c543

Please sign in to comment.