Skip to content
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>