Skip to content

Commit

Permalink
Fix optimization of Vector512 And + Not to AndNot (#108775)
Browse files Browse the repository at this point in the history
* Fix optimization of Vector512 And + Not to AndNot

Fixes #108613

* Fix test
  • Loading branch information
BruceForstall authored Oct 11, 2024
1 parent 4f69316 commit 7b67ab3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2030,7 +2030,7 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node)
{
transform = true;

op1 = opIntrin->Op(1);
op2 = opIntrin->Op(1);
BlockRange().Remove(opIntrin);

std::swap(op1, op2);
Expand Down
31 changes: 31 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_108613/Runtime_108613.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Reduced test case from Antigen.
//
// Failure:
// Assertion failed 'false && "found use of a node that is not in the LIR sequence"'

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

public class Runtime_108613
{
Vector512<uint> v512_uint_104 = Vector512.Create((uint)2, 3, 3, 57, 57, 57, 5, 2, 0, 2, 57, 57, 57, 2, 5, 2);
public int Method0()
{
Vector512<uint> x = Vector512.AndNot(Vector512.Equals(v512_uint_104, v512_uint_104), Vector512.Equals(v512_uint_104, v512_uint_104));
return (int)x.GetElement(2);
}

[Fact]
public static void TestEntryPoint()
{
if (Vector512.IsHardwareAccelerated)
{
Runtime_108613 t = new Runtime_108613();
Assert.Equal(0, t.Method0());
}
}
}
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>

0 comments on commit 7b67ab3

Please sign in to comment.