Skip to content
Snippets Groups Projects

Use loop bound canon to forkify demosaic

Merged rarbore2 requested to merge cava_opt_2 into main
2 files
+ 9
17
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -47,8 +47,6 @@ pub fn canonicalize_single_loop_bounds(
) -> bool {
let function = editor.func();
println!("canonicalizing {:?}", l.header);
let Some(loop_condition) = get_loop_exit_conditions(function, l, control_subgraph) else {
return false;
};
@@ -66,7 +64,6 @@ pub fn canonicalize_single_loop_bounds(
let ivs = compute_iv_ranges(editor, l, ivs, &loop_condition);
if has_canonical_iv(editor, l, &ivs).is_some() {
// println!("has canon iv!");
return false;
}
@@ -78,7 +75,6 @@ pub fn canonicalize_single_loop_bounds(
// Assume there is only one loop bound iv.
if loop_bound_ivs.len() != 1 {
// println!("has multiple iv!");
return false;
}
@@ -225,25 +221,15 @@ pub fn canonicalize_single_loop_bounds(
// If increment is negative (how in the world do we know that...)
// 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
.get_users(*update_expression)
.filter(|node| *node != iv.phi() && *node != condition_node)
.collect();
// println!("update_expr_users: {:?}", update_expr_users);
let iv_phi_users: Vec<_> = editor
.get_users(iv.phi())
.filter(|node| *node != iv.phi() && *node != *update_expression)
.collect();
// println!(" iv_phi_users: {:?}", iv_phi_users);
let result = editor.edit(|mut edit| {
// 4) Second, change loop IV to go from 0..N.
// we subtract off init from init and dc_bound_node,
@@ -270,7 +256,6 @@ pub fn canonicalize_single_loop_bounds(
edit.replace_all_uses_where(bound_id, new_condition, |usee| *usee == binop_node)?;
}
// for user in update_expr_users {
// let new_user = Node::Binary {
// left: user,
@@ -281,7 +266,7 @@ pub fn canonicalize_single_loop_bounds(
// edit = edit.replace_all_uses(user, new_user)?;
// }
// for
// for
// Add the offset back to users of the IV update expression
let new_user = Node::Binary {
@@ -311,6 +296,5 @@ pub fn canonicalize_single_loop_bounds(
Ok(edit)
});
println!("result: {:?}", result);
return result;
}
Loading