Skip to content
Snippets Groups Projects

Fork fission bufferize

Merged Xavier Routh requested to merge fork-fission-bufferize into main
All threads resolved!
6 files
+ 59
26
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -152,6 +152,7 @@ pub fn forkify_loop(
.filter(|id| !l.control[id.idx()])
.collect();
// FIXME: @xrouth
if loop_preds.len() != 1 {
return false;
}
@@ -388,6 +389,7 @@ nest! {
is_associative: bool,
},
LoopDependant(NodeID),
ControlDependant(NodeID), // This phi is redcutionable, but its cycle might depend on internal control within the loop.
UsedByDependant(NodeID),
}
}
@@ -398,6 +400,7 @@ impl LoopPHI {
LoopPHI::Reductionable { phi, .. } => *phi,
LoopPHI::LoopDependant(node_id) => *node_id,
LoopPHI::UsedByDependant(node_id) => *node_id,
LoopPHI::ControlDependant(node_id) => *node_id,
}
}
}
@@ -415,6 +418,9 @@ pub fn analyze_phis<'a>(
loop_nodes: &'a HashSet<NodeID>,
) -> impl Iterator<Item = LoopPHI> + 'a {
// We are also moving the phi from the top of the loop (the header),
// to the very end (the join). If there are uses of the phi somewhere in the loop,
// then they may try to use the phi (now a reduce) before it hits the join.
// Find data cycles within the loop of this phi,
// Start from the phis loop_continue_latch, and walk its uses until we find the original phi.
@@ -509,6 +515,12 @@ pub fn analyze_phis<'a>(
// to have headers that postdominate the loop continue latch. The value of the PHI used needs to be defined
// by the time the reduce is triggered (at the end of the loop's internal control).
// If anything in the intersection is a phi (that isn't this own phi), then the reduction cycle depends on control.
// Which is not allowed.
if intersection.iter().any(|cycle_node| editor.node(cycle_node).is_phi() && *cycle_node != *phi) || editor.node(loop_continue_latch).is_phi() {
return LoopPHI::ControlDependant(*phi);
}
// No nodes in data cycles with this phi (in the loop) are used outside the loop, besides the loop_continue_latch.
// If some other node in the cycle is used, there is not a valid node to assign it after making the cycle a reduce.
if intersection
Loading