Skip to content
Snippets Groups Projects
Commit ab5b00cf authored by Russel Arbore's avatar Russel Arbore
Browse files

Loop bound canon in cava + forkify

parent f0018604
No related branches found
No related tags found
1 merge request!189Use loop bound canon to forkify demosaic
Pipeline #201750 failed
This commit is part of merge request !189. Comments created here will be created in the context of that merge request.
...@@ -47,8 +47,6 @@ pub fn canonicalize_single_loop_bounds( ...@@ -47,8 +47,6 @@ pub fn canonicalize_single_loop_bounds(
) -> bool { ) -> bool {
let function = editor.func(); let function = editor.func();
println!("canonicalizing {:?}", l.header);
let Some(loop_condition) = get_loop_exit_conditions(function, l, control_subgraph) else { let Some(loop_condition) = get_loop_exit_conditions(function, l, control_subgraph) else {
return false; return false;
}; };
...@@ -66,7 +64,6 @@ pub fn canonicalize_single_loop_bounds( ...@@ -66,7 +64,6 @@ pub fn canonicalize_single_loop_bounds(
let ivs = compute_iv_ranges(editor, l, ivs, &loop_condition); let ivs = compute_iv_ranges(editor, l, ivs, &loop_condition);
if has_canonical_iv(editor, l, &ivs).is_some() { if has_canonical_iv(editor, l, &ivs).is_some() {
// println!("has canon iv!");
return false; return false;
} }
...@@ -78,7 +75,6 @@ pub fn canonicalize_single_loop_bounds( ...@@ -78,7 +75,6 @@ pub fn canonicalize_single_loop_bounds(
// Assume there is only one loop bound iv. // Assume there is only one loop bound iv.
if loop_bound_ivs.len() != 1 { if loop_bound_ivs.len() != 1 {
// println!("has multiple iv!");
return false; return false;
} }
...@@ -225,25 +221,15 @@ pub fn canonicalize_single_loop_bounds( ...@@ -225,25 +221,15 @@ pub fn canonicalize_single_loop_bounds(
// If increment is negative (how in the world do we know that...) // If increment is negative (how in the world do we know that...)
// Increment can be DefinetlyPostiive, Unknown, DefinetlyNegative. // Increment can be DefinetlyPostiive, Unknown, DefinetlyNegative.
// // First, massage loop condition to be <, because that is normal!
// Also includes
// editor.edit(|mut edit| {
// }
// Collect immediate IV users
let update_expr_users: Vec<_> = editor let update_expr_users: Vec<_> = editor
.get_users(*update_expression) .get_users(*update_expression)
.filter(|node| *node != iv.phi() && *node != condition_node) .filter(|node| *node != iv.phi() && *node != condition_node)
.collect(); .collect();
// println!("update_expr_users: {:?}", update_expr_users);
let iv_phi_users: Vec<_> = editor let iv_phi_users: Vec<_> = editor
.get_users(iv.phi()) .get_users(iv.phi())
.filter(|node| *node != iv.phi() && *node != *update_expression) .filter(|node| *node != iv.phi() && *node != *update_expression)
.collect(); .collect();
// println!(" iv_phi_users: {:?}", iv_phi_users);
let result = editor.edit(|mut edit| { let result = editor.edit(|mut edit| {
// 4) Second, change loop IV to go from 0..N. // 4) Second, change loop IV to go from 0..N.
// we subtract off init from init and dc_bound_node, // we subtract off init from init and dc_bound_node,
...@@ -270,7 +256,6 @@ pub fn canonicalize_single_loop_bounds( ...@@ -270,7 +256,6 @@ pub fn canonicalize_single_loop_bounds(
edit.replace_all_uses_where(bound_id, new_condition, |usee| *usee == binop_node)?; edit.replace_all_uses_where(bound_id, new_condition, |usee| *usee == binop_node)?;
} }
// for user in update_expr_users { // for user in update_expr_users {
// let new_user = Node::Binary { // let new_user = Node::Binary {
// left: user, // left: user,
...@@ -281,7 +266,7 @@ pub fn canonicalize_single_loop_bounds( ...@@ -281,7 +266,7 @@ pub fn canonicalize_single_loop_bounds(
// edit = edit.replace_all_uses(user, new_user)?; // edit = edit.replace_all_uses(user, new_user)?;
// } // }
// for // for
// Add the offset back to users of the IV update expression // Add the offset back to users of the IV update expression
let new_user = Node::Binary { let new_user = Node::Binary {
...@@ -311,6 +296,5 @@ pub fn canonicalize_single_loop_bounds( ...@@ -311,6 +296,5 @@ pub fn canonicalize_single_loop_bounds(
Ok(edit) Ok(edit)
}); });
println!("result: {:?}", result);
return result; return result;
} }
...@@ -39,6 +39,13 @@ fixpoint { ...@@ -39,6 +39,13 @@ fixpoint {
simpl!(fuse1); simpl!(fuse1);
array-slf(fuse1); array-slf(fuse1);
loop-bound-canon(fuse1); loop-bound-canon(fuse1);
fixpoint {
forkify(fuse1);
fork-guard-elim(fuse1);
fork-coalesce(fuse1);
}
predication(fuse1);
simpl!(fuse1);
inline(fuse2); inline(fuse2);
no-memset(fuse2@res); no-memset(fuse2@res);
...@@ -116,6 +123,7 @@ simpl!(fuse5); ...@@ -116,6 +123,7 @@ simpl!(fuse5);
delete-uncalled(*); delete-uncalled(*);
simpl!(*); simpl!(*);
xdot[true](fuse1);
simpl!(fuse1); simpl!(fuse1);
unforkify(fuse1); unforkify(fuse1);
......
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