From 390620f46bea4d1ef95b5dde7db8d1633acb98ee Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Mon, 9 May 2022 08:10:19 -0700 Subject: [PATCH] JIT: minor enhancement to jump threading (#69022) Allow jump threading of branches with exceptions, provided the branch and the dominating branch are in the same EH region. --- src/coreclr/jit/redundantbranchopts.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/coreclr/jit/redundantbranchopts.cpp b/src/coreclr/jit/redundantbranchopts.cpp index 621e395312a7..00986c3699c7 100644 --- a/src/coreclr/jit/redundantbranchopts.cpp +++ b/src/coreclr/jit/redundantbranchopts.cpp @@ -421,10 +421,11 @@ bool Compiler::optJumpThread(BasicBlock* const block, BasicBlock* const domBlock assert(tree->OperIs(GT_JTRUE)); if ((tree->gtFlags & GTF_SIDE_EFFECT) == GTF_EXCEPT) { - // However, be conservative if block is in a try as we might not - // have a full picture of EH flow. + // However, be conservative if the blocks are not in the + // same EH region, as we might not be able to fully + // describe control flow between them. // - if (!block->hasTryIndex()) + if (BasicBlock::sameEHRegion(block, domBlock)) { // We will ignore the side effect on this tree. //