Skip to content

Commit

Permalink
🔒 Fix incorrect scheduling for 3+ commutative operators
Browse files Browse the repository at this point in the history
  • Loading branch information
Philogy committed May 11, 2024
1 parent 711c752 commit df45004
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions examples/addmod.balls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn HEY(x, y) -> (z) {
z = addmod(x, y, 3)
}
10 changes: 6 additions & 4 deletions src/scheduling/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,14 @@ impl BackwardsMachine {
};

if undoing_as_variant {
let operands: Vec<_> = info.nodes[id].operands.iter().rev().collect();
info.variants[id]
let variant = info.variants[id]
.as_ref()
.expect("undoing_as_variant flag without variant")
.expect("undoing_as_variant flag without variant");
let operands = &info.nodes[id].operands;
variant
.iter()
.for_each(|op_index| push_to_stack(operands[*op_index]));
.rev()
.for_each(|op_index| push_to_stack(&operands[*op_index]));
} else {
info.nodes[id].operands.iter().rev().for_each(push_to_stack);
}
Expand Down

0 comments on commit df45004

Please sign in to comment.