Skip to content

Commit 12fc904

Browse files
Fix the VN for xor operation (#92372)
Co-authored-by: Kunal Pathak <Kunal.Pathak@microsoft.com>
1 parent 1757497 commit 12fc904

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

src/coreclr/jit/valuenum.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7891,7 +7891,7 @@ ValueNum ValueNumStore::EvalHWIntrinsicFunBinary(var_types type,
78917891
#endif
78927892
{
78937893
// Handle `x ^ x == 0`
7894-
return arg0VN;
7894+
return VNZeroForType(type);
78957895
}
78967896

78977897
default:
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
//
4+
// This test verifies if we correctly value number the operation of
5+
// x ^ x to zero.
6+
//
7+
// Found by Antigen
8+
9+
using System.Runtime.CompilerServices;
10+
using System.Runtime.Intrinsics;
11+
using Xunit;
12+
13+
public class Issue_91252
14+
{
15+
static Vector64<int> s_v64_int_22 = Vector64.Create(-5);
16+
Vector64<int> v64_int_72 = Vector64.Create(-1);
17+
18+
[MethodImpl(MethodImplOptions.NoInlining)]
19+
public int Repro()
20+
{
21+
s_v64_int_22 = v64_int_72;
22+
return Check(v64_int_72 ^ v64_int_72);
23+
}
24+
25+
[MethodImpl(MethodImplOptions.NoInlining)]
26+
public int Check(Vector64<int> a)
27+
{
28+
return (a == Vector64<int>.Zero) ? 100 : 101;
29+
}
30+
31+
[Fact]
32+
public static int EntryPoint()
33+
{
34+
var obj = new Issue_91252();
35+
return obj.Repro();
36+
}
37+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Optimize>True</Optimize>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Compile Include="$(MSBuildProjectName).cs" />
7+
</ItemGroup>
8+
</Project>

0 commit comments

Comments
 (0)