Skip to content

Commit df45004

Browse files
committed
🔒 Fix incorrect scheduling for 3+ commutative operators
1 parent 711c752 commit df45004

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

‎examples/addmod.balls

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn HEY(x, y) -> (z) {
2+
z = addmod(x, y, 3)
3+
}

‎src/scheduling/machine.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,14 @@ impl BackwardsMachine {
258258
};
259259

260260
if undoing_as_variant {
261-
let operands: Vec<_> = info.nodes[id].operands.iter().rev().collect();
262-
info.variants[id]
261+
let variant = info.variants[id]
263262
.as_ref()
264-
.expect("undoing_as_variant flag without variant")
263+
.expect("undoing_as_variant flag without variant");
264+
let operands = &info.nodes[id].operands;
265+
variant
265266
.iter()
266-
.for_each(|op_index| push_to_stack(operands[*op_index]));
267+
.rev()
268+
.for_each(|op_index| push_to_stack(&operands[*op_index]));
267269
} else {
268270
info.nodes[id].operands.iter().rev().for_each(push_to_stack);
269271
}

0 commit comments

Comments
 (0)