mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 03:26:06 +00:00

This work feeds part of PR https://github.com/llvm/llvm-project/pull/88385, and adds support for vectorising loops with uncountable early exits and outside users of loop-defined variables. When calculating the final value from an uncountable early exit we need to calculate the vector lane that triggered the exit, and hence determine the value at the point we exited. All code for calculating the last value when exiting the loop early now lives in a new vector.early.exit block, which sits between the middle.split block and the original exit block. Doing this required two fixes: 1. The vplan verifier incorrectly assumed that the block containing a definition always dominates the block of the user. That's not true if you can arrive at the use block from multiple incoming blocks. This is possible for early exit loops where both the early exit and the latch jump to the same block. 2. We were adding the new vector.early.exit to the wrong parent loop. It needs to have the same parent as the actual early exit block from the original loop. I've added a new ExtractFirstActive VPInstruction that extracts the first active lane of a vector, i.e. the lane of the vector predicate that triggered the exit. NOTE: The IR generated for dealing with live-outs from early exit loops is unoptimised, as opposed to normal loops. This inevitably leads to poor quality code, but this can be fixed up later.
46 lines
792 B
Plaintext
46 lines
792 B
Plaintext
digraph VPlan {
|
|
graph [labelloc=t, fontsize=30; label=""]
|
|
node [shape=rect, fontname=Courier, fontsize=30]
|
|
edge [fontname=Courier, fontsize=30]
|
|
compound=true
|
|
N1 [label =
|
|
"vector.ph"
|
|
]
|
|
N1 -> N2 [ label="" lhead=cluster_N3]
|
|
subgraph cluster_N3 {
|
|
fontname=Courier
|
|
label="\<x1\> vector loop"
|
|
N2 [label =
|
|
"vector.body"
|
|
]
|
|
}
|
|
N2 -> N4 [ label="" ltail=cluster_N3]
|
|
N4 [label =
|
|
"middle.split"
|
|
]
|
|
N4 -> N5 [ label=""]
|
|
N4 -> N7 [ label=""]
|
|
N5 [label =
|
|
"vector.early.exit"
|
|
]
|
|
N5 -> N6 [ label=""]
|
|
N6 [label =
|
|
"early.exit"
|
|
]
|
|
N7 [label =
|
|
"middle.block"
|
|
]
|
|
N7 -> N10 [ label=""]
|
|
N7 -> N8 [ label=""]
|
|
N8 [label =
|
|
"scalar.ph"
|
|
]
|
|
N8 -> N9 [ label=""]
|
|
N9 [label =
|
|
"loop.header"
|
|
]
|
|
N10 [label =
|
|
"latch.exit"
|
|
]
|
|
}
|