Skip to content
Snippets Groups Projects
Commit af6ff78a authored by Ryan Ziegler's avatar Ryan Ziegler
Browse files

reassociation go brr part 2

parent b3c5aade
No related branches found
No related tags found
No related merge requests found
Pipeline #202572 failed
......@@ -108,19 +108,26 @@ fn reassociate_chain<'a, 'b>(
.iter()
.map(|node_id| match get_uses(edit.get_node(*node_id)) {
NodeUses::Two([lhs, rhs]) => {
if edit.get_node(lhs).try_binary(op).is_none() {
lhs
} else if edit.get_node(rhs).try_binary(op).is_none() {
rhs
} else {
let mut inputs_local = vec![];
let lhs_is_input = edit.get_node(lhs).try_binary(op).is_none();
if lhs_is_input {
inputs_local.push(lhs);
}
let rhs_is_input = edit.get_node(rhs).try_binary(op).is_none();
if rhs_is_input {
inputs_local.push(rhs);
}
if !lhs_is_input && !rhs_is_input {
panic!("Node in chain has no valid inputs for reassociation");
}
inputs_local
}
_ => panic!(
"Unexpected node found in chain: {:?}",
edit.get_node(*node_id)
),
})
.flatten()
.collect::<Vec<_>>();
// 2. Add the reduction tree over the inputs. At this point, we expect
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment