Skip to content

Commit

Permalink
Fix the operands of NI_AVX512F_TernaryLogic during lowering (dotnet#1…
Browse files Browse the repository at this point in the history
…07813)

* fix the operands for TernaryLogicUseFlags

* Add test case

* Revert "fix the operands for TernaryLogicUseFlags"

This reverts commit 5b01643.

* proper fix

* trim test

* wrap test in try-catch

* Revert "wrap test in try-catch"

This reverts commit 3319875.

* wrap in Avx512F.IsSupported
  • Loading branch information
kunalspathak authored Sep 16, 2024
1 parent b3d440f commit 76f10f9
Show file tree
Hide file tree
Showing 3 changed files with 46 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 @@ -3901,7 +3901,7 @@ GenTree* Lowering::LowerHWIntrinsicTernaryLogic(GenTreeHWIntrinsic* node)
std::swap(node->Op(1), node->Op(2));

// Make sure we also fixup the control byte
control = TernaryLogicInfo::GetTernaryControlByte(info, C, A, B);
control = TernaryLogicInfo::GetTernaryControlByte(info, B, C, A);
op4->AsIntCon()->SetIconValue(control);

useFlags = TernaryLogicUseFlags::BC;
Expand Down
37 changes: 37 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_107587/Runtime_107587.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.

// Found by Antigen
// Reduced from 20.86 KB to 1.7 KB.
// JIT assert failed:
// Assertion failed 'unreached' in 'Runtime_107587:Method0():this' during 'Lowering nodeinfo' (IL size 133; hash 0x46e9aa75; FullOpts)

// File: D:\a\_work\1\s\src\coreclr\jit\lowerxarch.cpp Line: 11752

using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;
using System.Numerics;
using Xunit;

public class Runtime_107587
{
static Vector512<sbyte> s_v512_sbyte_42 = Vector512.Create((sbyte)92);
public Vector512<sbyte> Method0()
{
byte byte_152 = 3;
return Avx512F.TernaryLogic(s_v512_sbyte_42, s_v512_sbyte_42, s_v512_sbyte_42, byte_152);
}

[Fact]
public static void TestEntryPoint()
{
if (Avx512F.IsSupported)
{
new Runtime_107587().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 76f10f9

Please sign in to comment.