Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 1 addition & 4 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25982,9 +25982,6 @@ GenTree* Compiler::gtNewSimdMinMaxNode(var_types type,
needsFixup = cnsNode->IsFloatNegativeZero();
}
else
{
needsFixup = cnsNode->IsVectorZero();
}
{
needsFixup = cnsNode->IsVectorNegativeZero(simdBaseType);
}
Expand Down Expand Up @@ -31103,7 +31100,7 @@ genTreeOps GenTreeHWIntrinsic::GetOperForHWIntrinsicId(bool* isScalar, bool getE
{
oper = GT_NEG;
}
else if (isScalar && op1->IsCnsVec() && op1->AsVecCon()->IsScalarZero(simdBaseType))
else if (*isScalar && op1->IsCnsVec() && op1->AsVecCon()->IsScalarZero(simdBaseType))
Comment thread
tannergooding marked this conversation as resolved.
{
oper = GT_NEG;
}
Expand Down
27 changes: 27 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_130830/Runtime_130830.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.

namespace Runtime_130830;

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

public static class Runtime_130830
{
[Fact]
public static void TestEntryPoint()
{
Vector128<int> result = Test(Vector128.Create(10), Vector128.Create(100));
Assert.Equal(Vector128.Create(90, 91, 92, 93), result);
}
Comment thread
tannergooding marked this conversation as resolved.

// The low lane of the constant is zero but the constant is not all-zero, so the
// subtract must not be treated as a negate; otherwise the constant is dropped and
// the result collapses to <90, 90, 90, 90>.
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
private static Vector128<int> Test(Vector128<int> v1, Vector128<int> v2)
{
return (Vector128.Create(0, 1, 2, 3) - v1) + v2;
}
}
33 changes: 33 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_130831/Runtime_130831.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Runtime_130831;

using System.Runtime.CompilerServices;
using Xunit;

public static class Runtime_130831
{
// xunit's Assert.Equal for float/double compares bitwise, so it distinguishes -0.0 from +0.0.
[Fact]
public static void TestEntryPoint()
{
Assert.Equal(-0.0, MinNegZeroConst(+0.0));
Assert.Equal(-0.0, MinNumberZeroConst(-0.0));

Assert.Equal(-0.0f, MinNegZeroConst(+0.0f));
Assert.Equal(-0.0f, MinNumberZeroConst(-0.0f));
}
Comment thread
tannergooding marked this conversation as resolved.
Comment thread
tannergooding marked this conversation as resolved.

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
private static double MinNegZeroConst(double value) => double.Min(value, -0.0);

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
private static double MinNumberZeroConst(double value) => double.MinNumber(value, +0.0);

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
private static float MinNegZeroConst(float value) => float.Min(value, -0.0f);

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
private static float MinNumberZeroConst(float value) => float.MinNumber(value, +0.0f);
}
Loading