Go to the first, previous, next, last section, table of contents.


Optimizations

extern BOOL OptBranchTwist(FILE *fp)

obsolete (is now part of layouter)

extern BOOL OptBranchConditional(FILE *fp)

If both branches of a conditional point to the same basic block the conditional is useless.

extern BOOL OptBranchForwarding(FILE *fp)

Forward branches over empty basic blocks.

extern BOOL OptBranchMerge(FILE *fp)

Merge basic blocks which are connected by a normal edge if the target basic block has no other incoming edges.

extern BOOL OptBlockDuplicate(FILE *fp)

currently disabled

extern BOOL OptConstantsOne(FILE *fp)

Compute constants faster.

extern BOOL OptConstantsTwo(FILE *fp)

Sophisticated constant propagation. We resuse a constant in some other register to (hopefully) reduce register usage. This is only done on the basic block level. We do not kill instructions but expect useless code to be eliminated by other optimizations. We also allow construction of values from other using either explict lda's or doing it implicitly for memory format instruction. Care must be taken to not construct values that point into code sections since those values may change!!!

extern BOOL OptDuplicateFunctions(FILE *fp)

Duplicate Functions. To reduce "bad data flow" into function called from unknown callsites, eg. "hell". All functions which have "normal" callsite and are called by hell are cloned (duplicated). The normal callsites will call one clone and hell will call the other.

extern BOOL OptInline(FILE *fp,BOOL usepath )

Inline Frequently Called Functions.

extern BOOL OptAvoidLoads(FILE *fp)

Avoid reloading of a value from memory. Pairs of store/load instruction that provably reference the same memory location are replace by a store/move pair.

extern BOOL OptCopyPropagation(FILE *fp)

Propagate copies. Uses of registers are replaced with uses of the oldest copy of that register. This optimization could be extended to make use of lda with nonzero offsets. To "freeze" the changes made by this optimization. Dead code should be removed right after it.

extern BOOL OptMoveElimination(FILE *fp)

Eliminate Moves

This optimization is a reasonable hack until we have a real register reallocator. The idea is that if we eliminate a move operation we

o save an instruction

o can potentially reduce the register usage

Given move x,y We have two options.

o we can make the defintion of x a defintion of y

o we can make all uses of y uses of x

The first option is explores here the second option is implicitly performed by the copy propagation elimination.

The interactions with the Copy Propagation Optimization are unclear.

Conditional moves are a pain in the butt and need very careful coding.

Once we have determined that optimization can be applied we need to do the following:

o the old defining instruction for x should now define y o each use of x should be converted into a use of y once target becomes redefined we are done

The problems is with conditional move instructions which do not really define their target register:

o when we look for the defining instruction for x r we will ignore condtional moves.

Some bad cases:

def x
use x
use y (bad)
move x,y
def x
move x,y
use y
redef y
use x (bad)

the following code appears in cos

def x
move x,y
condmove a,x
condmove y,z  (bad)

extern BOOL OptStackSaveRegs(FILE *fp)

Avoid Unneccessary Callee Register Savings Not implemented yet but code is scanning for opportunities and prints them.

extern BOOL OptDeleteStack(FILE *fp)

Delete Unused Stack. A stackframe which is never used will be deleted. This optimization seems to be not very effective. and prints them.

extern BOOL OptLeafSaveRegisters(FILE *fp)

Avoid Callee Save Registers in Leaf Functions CURRENTLY NOT USED.

extern BOOL OptCalleeSaveRegisters(FILE *fp)

Delete unused stacks. Currently almost identical to OptStackSaveRegs.

extern BOOL OptStackMerge(FILE *fp)

Merge stacks. This optimization tries to reduce the number of stack pointer manipulations to one at the beginning of the entry bbl and one before each return instruction.

extern BOOL OptTableJumps(FILE *fp)

Identify possible targets in a BT_JUMP basic block. If all targets can be identifies the block changes its type to BT_SWITCH

extern BOOL OptGprel(FILE *fp)

If all BT_JUMP block in a function have been converted into BT_SWITCH blocks. We feel it is safe to eliminate edges from HELL to GPREL32 basic blocks in this function.

extern void AbblInstallNewJumpTable(INDEX ibbl)

Given a basic block of type BT_SWITCH generate a new jumptable for it in the enlarged data section. This useful when we duplicated this basic block and now need to use a different jumptable than the original.

extern BOOL OptNormalizeInstructions(FILE *fp)

Normalize Instructions. Often there are several instruction which achieve the same effect eg, lda r0,5(r1) or add r1,5,r0. In order to reduce the number of cases to be considered by other optimizations we normalize instructions. Those normlization should be (but aren't) undone before scheduling picking the instruction which has the nicer scheduling behaviour, eg. use bis r5,r5,r6 instead of lda r6,0(r5)

extern BOOL OptEliminateNoops(FILE *fp)

Eliminate No-ops

extern BOOL OptRemoveUnreachableCode(FILE *fp)

Eliminate Unreachable Code .

extern BOOL OptUnlinkEmptyBbls(FILE *fp)

Eliminate Empty Basic Blocks. Remove empty basic blocks which must be a bt_norm basic block by forwarding its incoming edges to the next bbl Except if the basic block is a dummy entry basic block

extern BOOL OptPeepHole(FILE *fp)

Peephole optimizations and strength reductions

extern BOOL OptCondMoveOne(FILE *fp)

Conditional move generation Conditional moves are introduced for the basic block on the left hand side

      O
      |\
      | O
      |/
      O

extern BOOL OptCondMoveTwo(FILE *fp)

Conditional move generation. Conditional moves are introduced for the basic blocks in the middle

      O
     / \
    O   O
     \ /
      O


Go to the first, previous, next, last section, table of contents.