Skip to content

Commit 7308c4f

Browse files
authored
JIT: limited version of forward substitution for some relops (#61023)
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.
1 parent 0113832 commit 7308c4f

File tree

3 files changed

+383
-16
lines changed

3 files changed

+383
-16
lines changed

src/coreclr/jit/compiler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7470,6 +7470,7 @@ class Compiler
74707470
// Redundant branch opts
74717471
//
74727472
PhaseStatus optRedundantBranches();
7473+
bool optRedundantRelop(BasicBlock* const block);
74737474
bool optRedundantBranch(BasicBlock* const block);
74747475
bool optJumpThread(BasicBlock* const block, BasicBlock* const domBlock, bool domIsSameRelop);
74757476
bool optReachable(BasicBlock* const fromBlock, BasicBlock* const toBlock, BasicBlock* const excludedBlock);

0 commit comments

Comments
 (0)