Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/coreclr/jit/redundantbranchopts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,8 @@ bool Compiler::optRedundantDominatingBranch(BasicBlock* const block)
break;
}

currentBlock = skipSideEffectFreeBlocks(currentBlock);

// Make sure this conditional dominator branches to the same
// shared block as the original block.
//
Expand Down
24 changes: 24 additions & 0 deletions src/tests/JIT/opt/RedundantBranch/RedundantBranchDominating.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,26 @@ private static int Dom_04(int count)
return 3;
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static int Dom_05(int count)
{
if (count > 1)
{
if (count > 2)
{
if (count > 3)
{
if (count > 4)
{
return 1;
}
}
}
}

return 3;
}

private static void RunTest(string name, Func<int, int> func, int[] expectedResults, int[] expectedEffects)
{
s_effects = 0;
Expand Down Expand Up @@ -141,4 +161,8 @@ public static void TestDom03() =>
[Fact]
public static void TestDom04() =>
RunTest(nameof(Dom_04), Dom_04, new[] { 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1 }, new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });

[Fact]
public static void TestDom05() =>
RunTest(nameof(Dom_05), Dom_05, new[] { 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1 }, new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
Comment thread
hez2010 marked this conversation as resolved.
}
Loading