Skip to content

JIT: Avx.CompareScalar incorrectly folded with True/False comparison modes #125160

@saucecontrol

Description

@saucecontrol

Description

CompareScalar is supposed to return the upper elements of the first operand unchanged, but folding for True/False comparison modes returns a full Zero or AllBitsSet vector.

https://github.com/dotnet/runtime/blob/f62984ce62deecfb90a8ab991e972d1bc460b93e/src/coreclr/jit/gentree.cpp#L33828-L33842

Reproduction Steps

using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;

Console.WriteLine(CompareFalse(Vector128<float>.One, Vector128<float>.Zero));

[MethodImpl(MethodImplOptions.NoInlining)]
static Vector128<float> CompareFalse(Vector128<float> x, Vector128<float> y)
	=> Avx.CompareScalar(x, y, FloatComparisonMode.OrderedFalseSignaling);

Expected behavior

> dotnet run -c release -f net9.0

<0, 1, 1, 1>

Actual behavior

> dotnet run -c release -f net10.0

<0, 0, 0, 0>

Regression?

Yes

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions