Skip to content
Snippets Groups Projects

Loop canon bound fix

Merged Xavier Routh requested to merge loop-canon-bound-fix into main
5 files
+ 52
34
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -47,6 +47,8 @@ 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;
};
@@ -65,7 +67,7 @@ pub fn canonicalize_single_loop_bounds(
if has_canonical_iv(editor, l, &ivs).is_some() {
// println!("has canon iv!");
return true;
return false;
}
let loop_bound_iv_phis = get_loop_condition_ivs(editor, l, &ivs, &loop_condition);
@@ -268,17 +270,20 @@ pub fn canonicalize_single_loop_bounds(
edit.replace_all_uses_where(bound_id, new_condition, |usee| *usee == binop_node)?;
}
// Add back to uses of the IV
for user in update_expr_users {
let new_user = Node::Binary {
left: user,
right: *initializer,
op: BinaryOperator::Add,
};
let new_user = edit.add_node(new_user);
edit = edit.replace_all_uses(user, new_user)?;
}
// for user in update_expr_users {
// let new_user = Node::Binary {
// left: user,
// right: *initializer,
// op: BinaryOperator::Add,
// };
// let new_user = edit.add_node(new_user);
// edit = edit.replace_all_uses(user, new_user)?;
// }
// for
// Add the offset back to users of the IV update expression
let new_user = Node::Binary {
left: *update_expression,
right: *initializer,
@@ -292,6 +297,7 @@ pub fn canonicalize_single_loop_bounds(
&& *usee != condition_node
})?;
// Add the offset back to users of the IV directly
let new_user = Node::Binary {
left: *iv_phi,
right: *initializer,
@@ -305,5 +311,6 @@ pub fn canonicalize_single_loop_bounds(
Ok(edit)
});
println!("result: {:?}", result);
return result;
}
Loading