Skip to content

Commit c11b0e0

Browse files
authored
Fix SupportsSettingZeroFlag for shift/rotate nodes (#117960)
1 parent 5c1ba69 commit c11b0e0

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

src/coreclr/jit/gentree.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19914,7 +19914,13 @@ bool GenTree::IsArrayAddr(GenTreeArrAddr** pArrAddr)
1991419914
bool GenTree::SupportsSettingZeroFlag()
1991519915
{
1991619916
#if defined(TARGET_XARCH)
19917-
if (OperIs(GT_AND, GT_OR, GT_XOR, GT_ADD, GT_SUB, GT_NEG, GT_LSH, GT_RSH, GT_RSZ, GT_ROL, GT_ROR))
19917+
if (OperIs(GT_LSH, GT_RSH, GT_RSZ, GT_ROL, GT_ROR))
19918+
{
19919+
// Shift/Rotate instructions do not update the flags in case of count being zero.
19920+
return gtGetOp2()->IsNeverZero();
19921+
}
19922+
19923+
if (OperIs(GT_AND, GT_OR, GT_XOR, GT_ADD, GT_SUB, GT_NEG))
1991819924
{
1991919925
return true;
1992019926
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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.1 on 2025-05-29 20:01:16
5+
// Run on X64 Windows
6+
// Seed: 14412340127944514498-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 53.8 KiB to 0.7 KiB in 00:02:59
8+
// Debug: Prints 1 line(s)
9+
// Release: Prints 0 line(s)
10+
11+
using System;
12+
using System.Runtime.CompilerServices;
13+
using Xunit;
14+
15+
public class Runtime_116125
16+
{
17+
[Fact]
18+
public static void TestEntryPoint()
19+
{
20+
ushort y = 0;
21+
Problem(0, ref y);
22+
}
23+
24+
[MethodImpl(MethodImplOptions.NoInlining)]
25+
static void Problem(ulong x, ref ushort y)
26+
{
27+
if (x / ((0UL & y) | 1) <= 0)
28+
{
29+
30+
}
31+
else
32+
{
33+
throw new InvalidOperationException();
34+
}
35+
}
36+
}
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)