diff --git a/hercules_opt/src/gcm.rs b/hercules_opt/src/gcm.rs index 4a6365c8c68bd7714b529744be1cc2bd0259071a..4cee5e83a227d3c868bc7607146cdebfaeb0b4d5 100644 --- a/hercules_opt/src/gcm.rs +++ b/hercules_opt/src/gcm.rs @@ -221,6 +221,31 @@ fn preliminary_fixups( } } + // Add region nodes between join nodes and loop headers to aid in block + // placement. + for (_, join) in fork_join_map { + let control_user = editor + .get_users(*join) + .filter(|id| nodes[id.idx()].is_control()) + .next() + .unwrap(); + if nodes[control_user.idx()].is_fork() + || nodes[control_user.idx()] + .try_region() + .map(|preds| preds.len() > 1) + .unwrap_or(false) + { + let success = editor.edit(|mut edit| { + let region = edit.add_node(Node::Region { + preds: Box::new([*join]), + }); + edit.replace_all_uses_where(*join, region, |id| *id == control_user) + }); + assert!(success); + return true; + } + } + false } diff --git a/juno_samples/rodinia/bfs/src/cpu.sch b/juno_samples/rodinia/bfs/src/cpu.sch index 339782d6a84b6a43f31d81f5c9b23240dd10a292..2bd762b2ce8d3821a2971d8c7ad849fd722e5c5c 100644 --- a/juno_samples/rodinia/bfs/src/cpu.sch +++ b/juno_samples/rodinia/bfs/src/cpu.sch @@ -50,7 +50,7 @@ fork-tile[32, 0, false, true](init); let (outer, inner) = fork-reshape[[1], [0]](init); let init_body = outline(inner); -inline(bfs@loop1, bfs@loop2); +inline(bfs@cost_init, bfs@loop1, bfs@loop2); delete-uncalled(*); const-inline(*); simpl!(*);