Skip to content

Commit bd15721

Browse files
authored
Ignore always-true relops in optRelopTryInferWithOneEqualOperand (#117749)
1 parent 761d85e commit bd15721

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

src/coreclr/jit/redundantbranchopts.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,15 @@ bool Compiler::optRelopTryInferWithOneEqualOperand(const VNFuncApp& domApp,
688688

689689
if ((ifTrueStatus == RelopResult::Unknown) && (ifFalseStatus == RelopResult::Unknown))
690690
{
691+
JITDUMP("Can't infer from both true and false branches - bail out.\n")
692+
return false;
693+
}
694+
695+
if ((ifTrueStatus == RelopResult::AlwaysTrue) && (ifFalseStatus == RelopResult::AlwaysTrue))
696+
{
697+
// If it doesn't depend on the dominating relop - bail out, someone else will fold
698+
// this always-true condition.
699+
JITDUMP("Always true from both branches - bail out.\n")
691700
return false;
692701
}
693702

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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-30 09:55:02
5+
// Run on Arm64 MacOS
6+
// Seed: 17657029378323677877-vectort,vector64,vector128,armadvsimd,armadvsimdarm64,armaes,armarmbase,armarmbasearm64,armcrc32,armcrc32arm64,armdp,armrdm,armrdmarm64,armsha1,armsha256
7+
// Reduced from 183.5 KiB to 0.6 KiB in 00:00:39
8+
// Debug: Prints 0 line(s)
9+
// Release: Prints 1 line(s)
10+
11+
using System;
12+
using Xunit;
13+
14+
public class Runtime_116159
15+
{
16+
public static long[] s_3 = new long[]
17+
{
18+
0
19+
};
20+
public static int s_6;
21+
public static ulong[] s_9;
22+
23+
[Fact]
24+
public static void TestEntryPoint()
25+
{
26+
if (1 <= s_3[0])
27+
{
28+
s_9 = new ulong[]
29+
{
30+
0
31+
};
32+
}
33+
else
34+
{
35+
if (long.MinValue > s_3[0])
36+
{
37+
throw new Exception();
38+
}
39+
}
40+
}
41+
}
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)