Skip to content
Snippets Groups Projects
Commit 3491c89c authored by Russel Arbore's avatar Russel Arbore
Browse files

re-commute for dc eq check

parent d09efff4
No related branches found
No related tags found
1 merge request!111Normalize dynamic constants during typechecking
Pipeline #201029 passed
use std::cmp::{max, min};
use std::collections::HashMap;
use std::iter::zip;
......@@ -1152,8 +1153,15 @@ fn dyn_consts_match(
(DynamicConstant::Constant(x), DynamicConstant::Constant(y)) => x == y,
(DynamicConstant::Parameter(i), _) => input == dc_args[*i],
(DynamicConstant::Add(pl, pr), DynamicConstant::Add(il, ir))
| (DynamicConstant::Sub(pl, pr), DynamicConstant::Sub(il, ir))
| (DynamicConstant::Mul(pl, pr), DynamicConstant::Mul(il, ir))
| (DynamicConstant::Min(pl, pr), DynamicConstant::Min(il, ir))
| (DynamicConstant::Max(pl, pr), DynamicConstant::Max(il, ir)) => {
// Normalize for associative ops by always looking at smaller DC ID
// as left arm and larger DC ID as right arm.
dyn_consts_match(dynamic_constants, dc_args, min(*pl, *pr), min(*il, *ir))
&& dyn_consts_match(dynamic_constants, dc_args, max(*pl, *pr), max(*il, *ir))
}
(DynamicConstant::Sub(pl, pr), DynamicConstant::Sub(il, ir))
| (DynamicConstant::Div(pl, pr), DynamicConstant::Div(il, ir))
| (DynamicConstant::Rem(pl, pr), DynamicConstant::Rem(il, ir)) => {
dyn_consts_match(dynamic_constants, dc_args, *pl, *il)
......
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