org.jikesrvm.compilers.opt.controlflow
Class BranchSimplifier

java.lang.Object
  extended by org.jikesrvm.compilers.opt.controlflow.BranchSimplifier

public abstract class BranchSimplifier
extends Object

Simplify and canonicalize conditional branches with constant operands.

This module performs no analysis, it simply attempts to simplify any branching instructions of a basic block that have constant operands. The intent is that analysis modules can call this transformation engine, allowing us to share the simplification code among multiple analysis modules.


Constructor Summary
BranchSimplifier()
           
 
Method Summary
private static void insertTrueGuard(Instruction inst, RegisterOperand guard)
           
(package private) static boolean processIfCmp(IR ir, BasicBlock bb, Instruction s)
          Process IfCmp branch instruction
(package private) static boolean processIfCmp2(IR ir, BasicBlock bb, Instruction s)
          Process IfCmp2 branch instruction
(package private) static boolean processInlineGuard(IR ir, BasicBlock bb, Instruction s)
          Process InlineGuard branch instruction
(package private) static boolean processLookupSwitch(IR ir, BasicBlock bb, Instruction s)
          Process LookupSwitch branch instruction
(package private) static boolean processTableSwitch(IR ir, BasicBlock bb, Instruction s)
          Process TableSwitch branch instruction
private static void removeBranchesAfterGotos(BasicBlock bb)
          To maintain IR integrity, remove any branches that are after the first GOTO in the basic block.
static boolean simplify(BasicBlock bb, IR ir)
          Given a basic block, attempt to simplify any conditional branch instructions with constant operands.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BranchSimplifier

public BranchSimplifier()
Method Detail

simplify

public static boolean simplify(BasicBlock bb,
                               IR ir)
Given a basic block, attempt to simplify any conditional branch instructions with constant operands. The instruction will be mutated in place. The control flow graph will be updated, but the caller is responsible for calling BranchOptmizations after simplify has been called on all basic blocks in the IR to remove unreachable code.

Parameters:
bb - the basic block to simplify
Returns:
true if we do something, false otherwise.

processIfCmp

static boolean processIfCmp(IR ir,
                            BasicBlock bb,
                            Instruction s)
Process IfCmp branch instruction


processIfCmp2

static boolean processIfCmp2(IR ir,
                             BasicBlock bb,
                             Instruction s)
Process IfCmp2 branch instruction


processLookupSwitch

static boolean processLookupSwitch(IR ir,
                                   BasicBlock bb,
                                   Instruction s)
Process LookupSwitch branch instruction


processTableSwitch

static boolean processTableSwitch(IR ir,
                                  BasicBlock bb,
                                  Instruction s)
Process TableSwitch branch instruction


processInlineGuard

static boolean processInlineGuard(IR ir,
                                  BasicBlock bb,
                                  Instruction s)
Process InlineGuard branch instruction


removeBranchesAfterGotos

private static void removeBranchesAfterGotos(BasicBlock bb)
To maintain IR integrity, remove any branches that are after the first GOTO in the basic block.


insertTrueGuard

private static void insertTrueGuard(Instruction inst,
                                    RegisterOperand guard)