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

JIT: Fix illegal operand swapping in VectorXYZ.AndNot transformation #91882

Merged
merged 2 commits into from
Sep 11, 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
11 changes: 10 additions & 1 deletion src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11028,7 +11028,16 @@ GenTree* Compiler::fgOptimizeHWIntrinsic(GenTreeHWIntrinsic* node)
}
}

if (lhs == nullptr || rhs == nullptr)
if ((lhs == nullptr) || (rhs == nullptr))
{
break;
}

// Filter out side effecting cases for several reasons:
// 1. gtNewSimdBinOpNode may swap operand order.
// 2. The code above will swap operand order.
// 3. The code above does not handle GTF_REVERSE_OPS.
if (((lhs->gtFlags | rhs->gtFlags) & GTF_ALL_EFFECT) != 0)
{
break;
}
Expand Down
27 changes: 27 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_91855/Runtime_91855.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.aa

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

public class Runitme_91855
{
[Fact]
public static void TestEntryPoint()
{
Assert.Throws<DivideByZeroException>(() => Foo(null, 0));
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static Vector128<uint> Foo(C c, uint val)
{
return Vector128.Create<uint>(100u / val) & (c.V ^ Vector128<uint>.AllBitsSet);
}

private class C
{
public Vector128<uint> V;
}
}
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