[PATCH] D43256: [MBP] Move a latch block with conditional exit and multi predecessors to top of loop

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 7 15:31:27 PDT 2019


Carrot added a comment.

Some analysis of the test case changes.

test/CodeGen/AArch64/neg-imm.ll
The control flow graph looks like:

      entry
        |
        V
  -->for.body
  |     |\
  |     | \
  |     |  \
  |     | if.then3
  |     |  /
  |     | /
  |     |/
  ---for.inc
        |
        V
  for.cond.cleanup

The original layout is:

  entry
  for.body
  if.then3
  for.inc
  for.cond.cleanup

For each loop iteration there are two taken branches.

The new layout is:

  entry
  for.inc
  for.body
  if.then3
  for.cond.cleanup

For each loop iterations there is one taken branch.

test/CodeGen/AMDGPU/optimize-negated-cond.ll
The control flow of function @negated_cond_dominated_blocks is:

    bb
     |
     V
    bb4 <--
    /\    |
   /  \   |
  bb5 bb6 |
   \  /   |
    \/    |
    bb7 ---
     |
     V
    bb3

The original layout is:

bb
bb4
bb6
bb5
bb7
bb3

For each loop iteration there are two taken branches.

New layout is

bb
bb6
bb7
bb4
bb5
bb3

For each loop iterations there is one taken branch.

test/CodeGen/Hexagon/redundant-branching2.ll
It is also diamond shaped loop,

     |
    b3 <--
    /\   |
   /  \  |
  b4  b5 |
   \  /  |
    \/   |
    b6----
     |

Original layout is

b3
b4
b5
b6

New layout is

b5
b6
b3
b4

The new layout can reduce 1 taken branch per iteration.

test/CodeGen/X86/widen_arith-*.ll
The control flow graph is:

      entry
        |
        V
  -->forcond ---
  |     |      |
  |     V      |
  ---forbody   |
               |
               V
           afterfor

Original layout is:

entry
forbody
forcond
afterfor

New layout is:

entry
forcond
forbody
afterfor

It shouldn't have performance impact, but the new layout is more natrual, more readable.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43256/new/

https://reviews.llvm.org/D43256





More information about the llvm-commits mailing list