Skip to content
Snippets Groups Projects
Commit 8f22a8e2 authored by Xavier Routh's avatar Xavier Routh
Browse files

forkify fixes

parent 931ec954
No related branches found
No related tags found
1 merge request!103Forkify + Loop Canonicalization + Initial Fork Fission
...@@ -439,6 +439,10 @@ pub fn analyze_phis<'a>( ...@@ -439,6 +439,10 @@ pub fn analyze_phis<'a>(
phis: &'a [NodeID], phis: &'a [NodeID],
loop_nodes: &'a HashSet<NodeID>, loop_nodes: &'a HashSet<NodeID>,
) -> impl Iterator<Item = LoopPHI> + 'a { ) -> impl Iterator<Item = LoopPHI> + 'a {
// 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.
phis.into_iter().map(move |phi| { phis.into_iter().map(move |phi| {
let stop_on: HashSet<NodeID> = editor let stop_on: HashSet<NodeID> = editor
.node_ids() .node_ids()
...@@ -451,6 +455,12 @@ pub fn analyze_phis<'a>( ...@@ -451,6 +455,12 @@ pub fn analyze_phis<'a>(
return true; return true;
} }
} }
// This phi
if node == phi {
return true;
}
// External Reduce // External Reduce
if let Node::Reduce { if let Node::Reduce {
control, control,
...@@ -480,10 +490,9 @@ pub fn analyze_phis<'a>( ...@@ -480,10 +490,9 @@ pub fn analyze_phis<'a>(
.unwrap(); .unwrap();
let loop_continue_latch = editor.node(phi).try_phi().unwrap().1[continue_idx]; let loop_continue_latch = editor.node(phi).try_phi().unwrap().1[continue_idx];
// TODO: We may need to stop on exiting the loop for looking for data cycles.
let uses = walk_all_uses_stop_on(loop_continue_latch, editor, stop_on.clone()); let uses = walk_all_uses_stop_on(loop_continue_latch, editor, stop_on.clone());
let users = walk_all_users_stop_on(loop_continue_latch, editor, stop_on.clone()); let users = walk_all_users_stop_on(*phi, editor, stop_on.clone());
let other_stop_on: HashSet<NodeID> = editor let other_stop_on: HashSet<NodeID> = editor
.node_ids() .node_ids()
...@@ -514,8 +523,7 @@ pub fn analyze_phis<'a>( ...@@ -514,8 +523,7 @@ pub fn analyze_phis<'a>(
.collect(); .collect();
let mut uses_for_dependance = walk_all_uses_stop_on(loop_continue_latch, editor, other_stop_on);
let mut uses_for_dependance = walk_all_users_stop_on(loop_continue_latch, editor, other_stop_on);
let set1: HashSet<_> = HashSet::from_iter(uses); let set1: HashSet<_> = HashSet::from_iter(uses);
let set2: HashSet<_> = HashSet::from_iter(users); let set2: HashSet<_> = HashSet::from_iter(users);
...@@ -539,7 +547,6 @@ pub fn analyze_phis<'a>( ...@@ -539,7 +547,6 @@ pub fn analyze_phis<'a>(
if intersection if intersection
.iter() .iter()
.filter(|node| **node != loop_continue_latch ) .filter(|node| **node != loop_continue_latch )
.filter(|node| !(editor.node(*node).is_reduce() || editor.node(*node).is_phi()))
.any(|data_node| { .any(|data_node| {
editor editor
.get_users(*data_node) .get_users(*data_node)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment