Skip to content

Commit 9897a3b

Browse files
Fix the isEmbeddedMaskingCompatible checks (#117607)
* Fix the isEmbeddedMaskingCompatible checks * Ensure the regression test is setup to use Xunit * Ensure the fuzzlyn test can actually run, not always throw
1 parent b9fb863 commit 9897a3b

File tree

3 files changed

+72
-12
lines changed

3 files changed

+72
-12
lines changed

src/coreclr/jit/gentree.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20737,7 +20737,7 @@ bool GenTree::isEmbeddedMaskingCompatible(Compiler* comp, unsigned tgtMaskSize,
2073720737
// Some intrinsics are effectively bitwise operations and so we
2073820738
// can freely update them to match the size of the actual mask
2073920739

20740-
bool supportsMaskBaseSize4Or8 = false;
20740+
bool supportsMaskBaseSize2Or4 = false;
2074120741

2074220742
switch (ins)
2074320743
{
@@ -20762,27 +20762,27 @@ bool GenTree::isEmbeddedMaskingCompatible(Compiler* comp, unsigned tgtMaskSize,
2076220762
case INS_xorpd:
2076320763
case INS_xorps:
2076420764
{
20765-
// These intrinsics support embedded broadcast and have masking support for 4 or 8
20766-
assert((maskBaseSize == 4) || (maskBaseSize == 8));
20765+
// These intrinsics support embedded broadcast and have masking support for 2 or 4
20766+
assert((maskBaseSize == 2) || (maskBaseSize == 4));
2076720767

2076820768
if (!comp->codeGen->IsEmbeddedBroadcastEnabled(ins, node->Op(2)))
2076920769
{
2077020770
// We cannot change the base type if we've already contained a broadcast
20771-
supportsMaskBaseSize4Or8 = true;
20771+
supportsMaskBaseSize2Or4 = true;
2077220772
}
2077320773
break;
2077420774
}
2077520775

2077620776
case INS_vpternlogd:
2077720777
case INS_vpternlogq:
2077820778
{
20779-
// These intrinsics support embedded broadcast and have masking support for 4 or 8
20780-
assert((maskBaseSize == 4) || (maskBaseSize == 8));
20779+
// These intrinsics support embedded broadcast and have masking support for 2 or 4
20780+
assert((maskBaseSize == 2) || (maskBaseSize == 4));
2078120781

2078220782
if (!comp->codeGen->IsEmbeddedBroadcastEnabled(ins, node->Op(3)))
2078320783
{
2078420784
// We cannot change the base type if we've already contained a broadcast
20785-
supportsMaskBaseSize4Or8 = true;
20785+
supportsMaskBaseSize2Or4 = true;
2078620786
}
2078720787
break;
2078820788
}
@@ -20812,9 +20812,9 @@ bool GenTree::isEmbeddedMaskingCompatible(Compiler* comp, unsigned tgtMaskSize,
2081220812
case INS_vinserti64x2:
2081320813
case INS_vinserti64x4:
2081420814
{
20815-
// These intrinsics don't support embedded broadcast and have masking support for 4 or 8
20816-
assert((maskBaseSize == 4) || (maskBaseSize == 8));
20817-
supportsMaskBaseSize4Or8 = true;
20815+
// These intrinsics don't support embedded broadcast and have masking support for 2 or 4
20816+
assert((maskBaseSize == 2) || (maskBaseSize == 4));
20817+
supportsMaskBaseSize2Or4 = true;
2081820818
break;
2081920819
}
2082020820

@@ -20824,9 +20824,9 @@ bool GenTree::isEmbeddedMaskingCompatible(Compiler* comp, unsigned tgtMaskSize,
2082420824
}
2082520825
}
2082620826

20827-
if (supportsMaskBaseSize4Or8)
20827+
if (supportsMaskBaseSize2Or4)
2082820828
{
20829-
if (tgtMaskBaseSize == 8)
20829+
if (tgtMaskBaseSize == 2)
2083020830
{
2083120831
if (varTypeIsFloating(simdBaseType))
2083220832
{
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
// Generated by Fuzzlyn v3.3 on 2025-07-14 11:26:52
5+
// Run on X64 Windows
6+
// Seed: 5654087083843205658-vectort,vector128,vector256,x86aes,x86avx,x86avx2,x86avx512bw,x86avx512bwvl,x86avx512cd,x86avx512cdvl,x86avx512dq,x86avx512dqvl,x86avx512f,x86avx512fvl,x86avx512fx64,x86bmi1,x86bmi1x64,x86bmi2,x86bmi2x64,x86fma,x86lzcnt,x86lzcntx64,x86pclmulqdq,x86popcnt,x86popcntx64,x86sse,x86ssex64,x86sse2,x86sse2x64,x86sse3,x86sse41,x86sse41x64,x86sse42,x86sse42x64,x86ssse3,x86x86base
7+
// Reduced from 33.4 KiB to 0.9 KiB in 00:01:30
8+
// Hits JIT assert for Release:
9+
// Assertion failed '(maskBaseSize == 4) || (maskBaseSize == 8)' in 'Program:M0()' during 'Rationalize IR' (IL size 87; hash 0xaf50ff37; FullOpts)
10+
//
11+
// File: D:\a\_work\1\s\src\coreclr\jit\gentree.cpp Line: 20819
12+
//
13+
14+
using System.Numerics;
15+
using System.Runtime.Intrinsics;
16+
using System.Runtime.Intrinsics.X86;
17+
using Xunit;
18+
19+
public class Runtime_117605
20+
{
21+
static Vector<uint>[] s_2;
22+
23+
[Fact]
24+
public static void TestEntryPoint()
25+
{
26+
if (Avx2.IsSupported)
27+
{
28+
M0();
29+
}
30+
}
31+
32+
private static void M0()
33+
{
34+
var vr3 = Vector256.Create(0, 7424648407429701945UL, 0, 0);
35+
var vr6 = Vector256.Create<ulong>(0);
36+
var vr7 = Vector128.CreateScalar(9831122154695836571UL);
37+
var vr4 = Avx2.InsertVector128(vr6, vr7, 0);
38+
var vr8 = Vector256.CreateScalar(1497050855019840058UL);
39+
var vr2 = Avx2.BlendVariable(vr3, vr4, vr8);
40+
C0 vr9 = new C0();
41+
var vr1 = vr9.M3(ref s_2, vr2);
42+
}
43+
44+
class C0
45+
{
46+
public short M3(ref Vector<uint>[] arg0, Vector256<ulong> arg1)
47+
{
48+
var vr5 = Vector128.Create(0, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0);
49+
return (short)Sse2.MoveMask(vr5);
50+
}
51+
}
52+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Optimize>True</Optimize>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Compile Include="$(MSBuildProjectName).cs" />
7+
</ItemGroup>
8+
</Project>

0 commit comments

Comments
 (0)