Skip to content

Commit

Permalink
JIT: limited version of forward substitution for some relops (#61023)
Browse files Browse the repository at this point in the history
Add a new optimization to redundant branch opts that looks at prior statements
in the same block for redundant relop trees. If one is found, we check to see
if it can be forward-substituted down to the terminal jump tree. And if it can
we duplicate the computation down at the jump.

This removes many of the cases we see in our generated code where we materialize
a boolean value in a register and then immediately test that register to see if
it is true/false, and then use that second test to drive branching -- instead we
now use the initial test logic to drive the jump and so the boolean value only
exists in the flags.
  • Loading branch information
AndyAyersMS authored Nov 3, 2021
1 parent 0113832 commit 7308c4f
Show file tree
Hide file tree
Showing 3 changed files with 383 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7470,6 +7470,7 @@ class Compiler
// Redundant branch opts
//
PhaseStatus optRedundantBranches();
bool optRedundantRelop(BasicBlock* const block);
bool optRedundantBranch(BasicBlock* const block);
bool optJumpThread(BasicBlock* const block, BasicBlock* const domBlock, bool domIsSameRelop);
bool optReachable(BasicBlock* const fromBlock, BasicBlock* const toBlock, BasicBlock* const excludedBlock);
Expand Down
Loading

0 comments on commit 7308c4f

Please sign in to comment.