Skip to content

Commit

Permalink
Add extra Simplifier & gotoElim passes to warm/hot
Browse files Browse the repository at this point in the history
If Simplifier detects trivial conditional branches where the fallthrough
block is a goto block to the branch target it can remove said branches
and leave behind a goto block. The resulting CFG can then potentially
be cleaned up by RedundantGotoElimination. Running these two opts
before BlockSplitter allows these trivial conditional branches to be
completely optimized away before BlockSplitter gets a change to run and
potentially duplicate blocks that hide the opportunity and make it
harder to detect and eliminate later.

This PR inserts Simplifer and RedundantGotoElimination passes before
BlockSplitter and moves all 3 after VP, which typically detects
opportunities that result in dead code, which when removed, results
in the trivial conditional branches that we're interested in.

Signed-off-by: Younes Manton <ymanton@ca.ibm.com>
  • Loading branch information
ymanton committed Sep 9, 2024
1 parent 90ac2bf commit 8d9a6bd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion runtime/compiler/optimizer/J9Optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ static const OptimizationStrategy warmStrategyOpts[] =
#endif
{ OMR::localCSE, OMR::IfLoopsAndNotProfiling },
{ OMR::idiomRecognition, OMR::IfLoopsAndNotProfiling },
{ OMR::treeSimplification },
{ OMR::redundantGotoElimination, OMR::IfEnabledAndNotJitProfiling },
{ OMR::blockSplitter },
{ OMR::treeSimplification }, // revisit; not really required ?
{ OMR::virtualGuardHeadMerger },
Expand Down Expand Up @@ -554,8 +556,9 @@ const OptimizationStrategy hotStrategyOpts[] =
{ OMR::earlyLocalGroup },
{ OMR::stripMiningGroup, OMR::IfLoops }, // strip mining in loops
{ OMR::loopReplicator, OMR::IfLoops }, // tail-duplication in loops
{ OMR::blockSplitter, OMR::IfNews }, // treeSimplification + blockSplitter + VP => opportunity for EA
{ OMR::expensiveGlobalValuePropagationGroup },
{ OMR::redundantGotoElimination, OMR::IfEnabledAndNotJitProfiling },
{ OMR::blockSplitter, OMR::IfNews }, // treeSimplification + blockSplitter + VP => opportunity for EA
{ OMR::localCSE, OMR::IfVectorAPI },
{ OMR::loopCanonicalization, OMR::IfVectorAPI },
{ OMR::partialRedundancyEliminationGroup, OMR::IfVectorAPI },
Expand Down

0 comments on commit 8d9a6bd

Please sign in to comment.