Skip to content
Snippets Groups Projects

Loop bound lte

Merged Xavier Routh requested to merge loop-bound-lte into main
3 files
+ 21
9
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -95,6 +95,8 @@ pub fn forkify_loop(
@@ -95,6 +95,8 @@ pub fn forkify_loop(
) -> bool {
) -> bool {
let function = editor.func();
let function = editor.func();
 
println!("forkifying {:?}", 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;
};
};
@@ -106,12 +108,13 @@ pub fn forkify_loop(
@@ -106,12 +108,13 @@ pub fn forkify_loop(
else {
else {
return false;
return false;
};
};
// Compute loop variance
// Compute loop variance
let loop_variance = compute_loop_variance(editor, l);
let loop_variance = compute_loop_variance(editor, l);
let ivs = compute_induction_vars(editor.func(), l, &loop_variance);
let ivs = compute_induction_vars(editor.func(), l, &loop_variance);
let ivs = compute_iv_ranges(editor, l, ivs, &loop_condition);
let ivs = compute_iv_ranges(editor, l, ivs, &loop_condition);
let Some(canonical_iv) = has_canonical_iv(editor, l, &ivs) else {
let Some(canonical_iv) = has_canonical_iv(editor, l, &ivs) else {
 
println!("no canonical iv");
return false;
return false;
};
};
@@ -130,6 +133,7 @@ pub fn forkify_loop(
@@ -130,6 +133,7 @@ pub fn forkify_loop(
};
};
let Some(bound_dc_id) = bound else {
let Some(bound_dc_id) = bound else {
 
println!("no bound iv");
return false;
return false;
};
};
@@ -167,6 +171,8 @@ pub fn forkify_loop(
@@ -167,6 +171,8 @@ pub fn forkify_loop(
return false;
return false;
}
}
 
println!("this one");
 
// Get all phis used outside of the loop, they need to be reductionable.
// Get all phis used outside of the loop, they need to be reductionable.
// For now just assume all phis will be phis used outside of the loop, except for the canonical iv.
// For now just assume all phis will be phis used outside of the loop, except for the canonical iv.
// FIXME: We need a different definiton of `loop_nodes` to check for phis used outside hte loop than the one
// FIXME: We need a different definiton of `loop_nodes` to check for phis used outside hte loop than the one
@@ -196,6 +202,9 @@ pub fn forkify_loop(
@@ -196,6 +202,9 @@ pub fn forkify_loop(
let loop_body_last = editor.get_uses(loop_if).next().unwrap();
let loop_body_last = editor.get_uses(loop_if).next().unwrap();
 
 
println!("phis {:?}", reductionable_phis);
 
if reductionable_phis
if reductionable_phis
.iter()
.iter()
.any(|phi| !matches!(phi, LoopPHI::Reductionable { .. }))
.any(|phi| !matches!(phi, LoopPHI::Reductionable { .. }))
@@ -403,6 +412,7 @@ pub fn forkify_loop(
@@ -403,6 +412,7 @@ pub fn forkify_loop(
Ok(edit)
Ok(edit)
});
});
 
println!("result: {:?}", result);
return result;
return result;
}
}
@@ -530,10 +540,11 @@ pub fn analyze_phis<'a>(
@@ -530,10 +540,11 @@ pub fn analyze_phis<'a>(
let intersection: HashSet<_> = set1.intersection(&set2).cloned().collect();
let intersection: HashSet<_> = set1.intersection(&set2).cloned().collect();
// If this phi uses any other phis the node is loop dependant,
// If this phi uses any other phis the node is loop dependant,
// we use `phis` because this phi can actually contain the loop iv and its fine.
// // we use `phis` because this phi can actually contain the loop iv and its fine.
if uses_for_dependance.any(|node| phis.contains(&node) && node != *phi) {
// if uses_for_dependance.any(|node| phis.contains(&node) && node != *phi) {
LoopPHI::LoopDependant(*phi)
// LoopPHI::LoopDependant(*phi)
} else if intersection.clone().iter().next().is_some() {
// } else
 
if intersection.clone().iter().next().is_some() {
// PHIs on the frontier of the uses by the candidate phi, i.e in uses_for_dependance need
// PHIs on the frontier of the uses by the candidate phi, i.e in uses_for_dependance need
// to have headers that postdominate the loop continue latch. The value of the PHI used needs to be defined
// to have headers that postdominate the loop continue latch. The value of the PHI used needs to be defined
// by the time the reduce is triggered (at the end of the loop's internal control).
// by the time the reduce is triggered (at the end of the loop's internal control).
Loading