Skip to content
  • Xavier Leroy's avatar
    Improve branch tunneling · 7f152e2f
    Xavier Leroy authored
    The previous branch tunneling was missing optimization opportunities
    introduced by the optimization of conditional branches.  For example:
    
    L1: instr; branch L2
    L2: if cond then branch L3 else branch L4
    L3: branch L4
    L4: ...
    
    was transformed into
    
    L1: instr; branch L2
    L2: branch L4
    L3: branch L4
    L4: ...
    
    missing a tunneling opportunity (branch L2 -> branch L4).
    
    This commit improves branch tunneling so that the expected code is produced:
    
    L1: instr; branch L4
    L2: branch L4
    L3: branch L4
    L4: ...
    
    To this end, additional equalities are introduced in the union-find
    data structure corresponding to optimizable conditional branches.
    
    In rare cases these additional equalities trigger new opportunities for
    optimizing conditional branches.  Hence we iterate the analysis
    until no optimizable conditional branch remains.
    7f152e2f