===== AST after parser ===== f(cond1, cond2): TreeList IfBranch UnresolvedReference cond1 TreeList BinaryOperation Declaration UnresolvedReference a MathematicalConstant 1 IfBranch UnresolvedReference cond2 TreeList BinaryOperation Declaration UnresolvedReference b UnresolvedReference a ElseIfBranch Else TreeList BinaryOperation Declaration UnresolvedReference b MathematicalConstant 3 ElseIfBranch Else TreeList BinaryOperation Declaration UnresolvedReference b MathematicalConstant 4 ReturnNode UnresolvedReference b ===== AST after if-branch-merging ===== f(cond1, cond2): TreeList IfElseIfChain UnresolvedReference cond1 TreeList BinaryOperation Declaration UnresolvedReference a MathematicalConstant 1 IfElseIfChain UnresolvedReference cond2 TreeList BinaryOperation Declaration UnresolvedReference b UnresolvedReference a TreeList BinaryOperation Declaration UnresolvedReference b MathematicalConstant 3 TreeList BinaryOperation Declaration UnresolvedReference b MathematicalConstant 4 ReturnNode UnresolvedReference b ===== AST after reference-resolving ===== f(cond1, cond2): TreeList IfElseIfChain Var cond1 TreeList BinaryOperation Assignment Var a MathematicalConstant 1 IfElseIfChain Var cond2 TreeList BinaryOperation Assignment Var b Var a TreeList BinaryOperation Assignment Var b MathematicalConstant 3 TreeList BinaryOperation Assignment Var b MathematicalConstant 4 ReturnNode Var b ===== AST after cfg-building ===== f(cond1, cond2): TreeList IfElseIfChain Var cond1 TreeList BinaryOperation Assignment Var a MathematicalConstant 1 IfElseIfChain Var cond2 TreeList BinaryOperation Assignment Var b Var a TreeList BinaryOperation Assignment Var b MathematicalConstant 3 TreeList BinaryOperation Assignment Var b MathematicalConstant 4 ReturnNode Var b ===== CFG after cfg-building ===== f(cond1, cond2): 0: ControlFlowBranch true=3 false=7 Var cond1 1: ControlFlowFunctionReturn Var $return 2: BinaryOperation Assignment Var $return Var b ControlFlowJump jump=1 3: BinaryOperation Assignment Var a MathematicalConstant 1 ControlFlowBranch true=5 false=6 Var cond2 4: ControlFlowJump jump=2 5: BinaryOperation Assignment Var b Var a ControlFlowJump jump=4 6: BinaryOperation Assignment Var b MathematicalConstant 3 ControlFlowJump jump=4 7: BinaryOperation Assignment Var b MathematicalConstant 4 ControlFlowJump jump=2 8: BinaryOperation Assignment Var $return Error "" ControlFlowJump jump=1 ===== AST after cfg-simplification ===== f(cond1, cond2): TreeList IfElseIfChain Var cond1 TreeList BinaryOperation Assignment Var a MathematicalConstant 1 IfElseIfChain Var cond2 TreeList BinaryOperation Assignment Var b Var a TreeList BinaryOperation Assignment Var b MathematicalConstant 3 TreeList BinaryOperation Assignment Var b MathematicalConstant 4 ReturnNode Var b ===== CFG after cfg-simplification ===== f(cond1, cond2): 0: ControlFlowBranch true=3 false=6 Var cond1 1: ControlFlowFunctionReturn Var $return 2: BinaryOperation Assignment Var $return Var b ControlFlowJump jump=1 3: BinaryOperation Assignment Var a MathematicalConstant 1 ControlFlowBranch true=4 false=5 Var cond2 4: BinaryOperation Assignment Var b Var a ControlFlowJump jump=2 5: BinaryOperation Assignment Var b MathematicalConstant 3 ControlFlowJump jump=2 6: BinaryOperation Assignment Var b MathematicalConstant 4 ControlFlowJump jump=2 ===== AST after ssa-building ===== f(cond1, cond2): TreeList IfElseIfChain Var cond1@0 TreeList BinaryOperation Assignment Var a@1 MathematicalConstant 1 IfElseIfChain Var cond2@0 TreeList BinaryOperation Assignment Var b@1 Var a@1 TreeList BinaryOperation Assignment Var b@3 MathematicalConstant 3 TreeList BinaryOperation Assignment Var b@4 MathematicalConstant 4 ReturnNode Var b@2 ===== CFG after ssa-building ===== f(cond1, cond2): 0: ControlFlowBranch true=1 false=6 Var cond1@0 1: BinaryOperation Assignment Var a@1 MathematicalConstant 1 ControlFlowBranch true=2 false=5 Var cond2@0 2: BinaryOperation Assignment Var b@1 Var a@1 ControlFlowJump jump=3 3: a@2 = phi(2: a@1, 5: a@1, 6: a@0) b@2 = phi(2: b@1, 5: b@3, 6: b@4) BinaryOperation Assignment Var $return@1 Var b@2 ControlFlowJump jump=4 4: ControlFlowFunctionReturn Var $return@1 5: BinaryOperation Assignment Var b@3 MathematicalConstant 3 ControlFlowJump jump=3 6: BinaryOperation Assignment Var b@4 MathematicalConstant 4 ControlFlowJump jump=3 ===== AST after dce ===== f(cond1, cond2): TreeList IfElseIfChain Var cond1@0 TreeList BinaryOperation Assignment Var a@1 MathematicalConstant 1 IfElseIfChain Var cond2@0 TreeList BinaryOperation Assignment Var b@1 Var a@1 TreeList BinaryOperation Assignment Var b@3 MathematicalConstant 3 TreeList BinaryOperation Assignment Var b@4 MathematicalConstant 4 ReturnNode Var b@2 ===== CFG after dce ===== f(cond1, cond2): 0: ControlFlowBranch true=1 false=6 Var cond1@0 1: BinaryOperation Assignment Var a@1 MathematicalConstant 1 ControlFlowBranch true=2 false=5 Var cond2@0 2: BinaryOperation Assignment Var b@1 Var a@1 ControlFlowJump jump=3 3: b@2 = phi(2: b@1, 5: b@3, 6: b@4) BinaryOperation Assignment Var $return@1 Var b@2 ControlFlowJump jump=4 4: ControlFlowFunctionReturn Var $return@1 5: BinaryOperation Assignment Var b@3 MathematicalConstant 3 ControlFlowJump jump=3 6: BinaryOperation Assignment Var b@4 MathematicalConstant 4 ControlFlowJump jump=3