Skip to content

Commit

Permalink
restrict merge-left-shift
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Dec 19, 2024
1 parent 8596aad commit ceeaad9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion patronus-egraphs/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ pub fn create_rewrites() -> Vec<ArithRewrite> {
arith_rewrite!("merge-left-shift";
// we require that b, c and (b + c) are all unsigned
// we do not want (b + c) to wrap, because in that case the result would always be zero
"(<< ?wo ?wab unsign (<< ?wab ?wa ?sa ?a ?wb unsign ?b) ?wc unsign ?c)" =>
// the value being shifted has to be consistently signed or unsigned
"(<< ?wo ?wab ?sa (<< ?wab ?wa ?sa ?a ?wb unsign ?b) ?wc unsign ?c)" =>
"(<< ?wo ?wa ?sa ?a (max+1 ?wb ?wc) unsign (+ (max+1 ?wb ?wc) ?wb unsign ?b ?wc unsign ?c))";
// wab >= wo
if["?wo", "?wab"], |w| w[1] >= w[0]),
Expand Down

0 comments on commit ceeaad9

Please sign in to comment.