Skip to content

Commit

Permalink
Revert "Trying something..."
Browse files Browse the repository at this point in the history
This reverts commit 16dd32f.
  • Loading branch information
asterite committed Nov 7, 2024
1 parent 59aed41 commit 71e2b29
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions compiler/noirc_evaluator/src/ssa/opt/unrolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ fn unroll_loop(
cfg: &ControlFlowGraph,
loop_: &Loop,
) -> Result<(), CallStack> {
let mut unroll_into = get_pre_header(cfg, loop_)?;
let mut unroll_into = get_pre_header(cfg, loop_);
let mut jump_value = get_induction_variable(function, unroll_into)?;

while let Some(context) = unroll_loop_header(function, loop_, unroll_into, jump_value)? {
Expand All @@ -233,17 +233,14 @@ fn unroll_loop(
/// The loop pre-header is the block that comes before the loop begins. Generally a header block
/// is expected to have 2 predecessors: the pre-header and the final block of the loop which jumps
/// back to the beginning.
fn get_pre_header(cfg: &ControlFlowGraph, loop_: &Loop) -> Result<BasicBlockId, CallStack> {
fn get_pre_header(cfg: &ControlFlowGraph, loop_: &Loop) -> BasicBlockId {
let mut pre_header = cfg
.predecessors(loop_.header)
.filter(|predecessor| *predecessor != loop_.back_edge_start)
.collect::<Vec<_>>();

if pre_header.len() == 1 {
Ok(pre_header.remove(0))
} else {
Err(CallStack::new())
}
assert_eq!(pre_header.len(), 1);
pre_header.remove(0)
}

/// Return the induction value of the current iteration of the loop, from the given block's jmp arguments.
Expand Down

0 comments on commit 71e2b29

Please sign in to comment.