Skip to content

JIT: Mask AND with zero incorrectly folded #123399

@saucecontrol

Description

@saucecontrol

Description

AND between a mask and a constant zero is incorrectly folded to the mask value in net10.0.

https://github.com/dotnet/runtime/blob/2075e8ffaa8cf598dac9c09f5f690778ef1a6c8e/src/coreclr/jit/gentree.cpp#L32988-L32992

Reproduction Steps

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

Console.WriteLine(AndMaskZero(Vector512<int>.One));

[MethodImpl(MethodImplOptions.NoInlining)]
static Vector512<int> AndMaskZero(Vector512<int> v) =>
	Vector512.Equals(v, v) & Vector512.LessThan(v.AsUInt32(), Vector512<uint>.Zero).AsInt32();

Expected behavior

> dotnet run -c release -f net9.0

<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>

Actual behavior

> dotnet run -c release -f net10.0

<-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1>

Regression?

Yes, worked in 9.0

Configuration

Requires AVX-512

Metadata

Metadata

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIavx512Related to the AVX-512 architecturebug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions