Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the VN for xor operation #91503

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7883,7 +7883,7 @@ ValueNum ValueNumStore::EvalHWIntrinsicFunBinary(var_types type,
#endif
{
// Handle `x ^ x == 0`
return arg0VN;
return VNZeroForType(type);
}

default:
Expand Down
37 changes: 37 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_91252/Runtime_91252.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
// This test verifies if we correctly value number the operation of
// x ^ x to zero.
//
// Found by Antigen

using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using Xunit;

public class Issue_91252
{
static Vector64<int> s_v64_int_22 = Vector64.Create(-5);
Vector64<int> v64_int_72 = Vector64.Create(-1);

[MethodImpl(MethodImplOptions.NoInlining)]
public int Repro()
{
s_v64_int_22 = v64_int_72;
return Check(v64_int_72 ^ v64_int_72);
}

[MethodImpl(MethodImplOptions.NoInlining)]
public int Check(Vector64<int> a)
{
return (a == Vector64<int>.Zero) ? 100 : 101;
}

[Fact]
public static int EntryPoint()
{
var obj = new Issue_91252();
return obj.Repro();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
Loading