diff --git a/src/coreclr/jit/redundantbranchopts.cpp b/src/coreclr/jit/redundantbranchopts.cpp index d430abe5171cdc..9528ac3065f798 100644 --- a/src/coreclr/jit/redundantbranchopts.cpp +++ b/src/coreclr/jit/redundantbranchopts.cpp @@ -688,6 +688,15 @@ bool Compiler::optRelopTryInferWithOneEqualOperand(const VNFuncApp& domApp, if ((ifTrueStatus == RelopResult::Unknown) && (ifFalseStatus == RelopResult::Unknown)) { + JITDUMP("Can't infer from both true and false branches - bail out.\n") + return false; + } + + if ((ifTrueStatus == RelopResult::AlwaysTrue) && (ifFalseStatus == RelopResult::AlwaysTrue)) + { + // If it doesn't depend on the dominating relop - bail out, someone else will fold + // this always-true condition. + JITDUMP("Always true from both branches - bail out.\n") return false; } diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_116159/Runtime_116159.cs b/src/tests/JIT/Regression/JitBlue/Runtime_116159/Runtime_116159.cs new file mode 100644 index 00000000000000..aee209ac6cee71 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_116159/Runtime_116159.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// Generated by Fuzzlyn v3.1 on 2025-05-30 09:55:02 +// Run on Arm64 MacOS +// Seed: 17657029378323677877-vectort,vector64,vector128,armadvsimd,armadvsimdarm64,armaes,armarmbase,armarmbasearm64,armcrc32,armcrc32arm64,armdp,armrdm,armrdmarm64,armsha1,armsha256 +// Reduced from 183.5 KiB to 0.6 KiB in 00:00:39 +// Debug: Prints 0 line(s) +// Release: Prints 1 line(s) + +using System; +using Xunit; + +public class Runtime_116159 +{ + public static long[] s_3 = new long[] + { + 0 + }; + public static int s_6; + public static ulong[] s_9; + + [Fact] + public static void TestEntryPoint() + { + if (1 <= s_3[0]) + { + s_9 = new ulong[] + { + 0 + }; + } + else + { + if (long.MinValue > s_3[0]) + { + throw new Exception(); + } + } + } +} \ No newline at end of file diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_116159/Runtime_116159.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_116159/Runtime_116159.csproj new file mode 100644 index 00000000000000..de6d5e08882e86 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_116159/Runtime_116159.csproj @@ -0,0 +1,8 @@ + + + True + + + + +