And then the following instructions usually compare and branch on the R2 result.
Difficulty: Medium
One solution here is to use tail duplication to duplicate the continue block in each branch.
This will allow branch optimisations to act more easily and collapse useless branching when the outcome becomes evident (since it’s true in one and false in the other)
Cmp R0 R1
JumpGreater true
R2 := false
continue’:
Cmp R2 true // Now this branch is always false!!!
JumpEquals A
Jump B
true:
R2 := true
continue’’:
Cmp R2 true // Now this branch is always true!!!
JumpEquals A
Jump B
== Branch fold ==>
Cmp R0 R1
JumpGreater true
R2 := false // Now this is dead code!
continue’:
Jump B
true:
R2 := true // Now this is dead code!
continue’’:
Jump A
== dead code elimination ==>
Cmp R0 R1
JumpGreater true
continue’:
Jump B
true:
Jump A
Cogit does not support GetConditionCode instructions and we translated them to a branch sequence. This means:
Example
Right now, they are compiled to:
=>
And then the following instructions usually compare and branch on the R2 result.
Difficulty: Medium
One solution here is to use tail duplication to duplicate the continue block in each branch. This will allow branch optimisations to act more easily and collapse useless branching when the outcome becomes evident (since it’s true in one and false in the other)
== Tail duplicate ==>
== Branch fold ==>
== dead code elimination ==>
== Remove Empty basic block ==>