[sledge] Prefer constants as class reps

Reviewed By: jvillard

Differential Revision: D14344292

fbshipit-source-id: b337f371a
master
Josh Berdine 6 years ago committed by Facebook Github Bot
parent a4a9d5682e
commit 71694c874f

@ -1288,9 +1288,13 @@ let solve e f =
let rec solve_ e f s = let rec solve_ e f s =
let solve_uninterp e f = let solve_uninterp e f =
let ord = compare e f in let ord = compare e f in
if is_constant e && is_constant f && ord <> 0 then None match (is_constant e, is_constant f) with
else | true, true when ord <> 0 -> None
(* orient equation to choose preferred class representative *) (* orient equation to discretionarily prefer exp that is constant or
compares smaller as class representative *)
| true, false -> Some (Map.add_exn s ~key:f ~data:e)
| false, true -> Some (Map.add_exn s ~key:e ~data:f)
| _ ->
let key, data = if ord > 0 then (e, f) else (f, e) in let key, data = if ord > 0 then (e, f) else (f, e) in
Some (Map.add_exn s ~key ~data) Some (Map.add_exn s ~key ~data)
in in
@ -1304,10 +1308,7 @@ let solve e f =
let d = rational (Q.neg q) typ in let d = rational (Q.neg q) typ in
let r = div n d in let r = div n d in
Some (Map.add_exn s ~key:c ~data:r) Some (Map.add_exn s ~key:c ~data:r)
| e_f -> | e_f -> solve_uninterp e_f (integer Z.zero typ) )
let z = integer Z.zero typ in
if is_constant e_f && not (equal e_f z) then None
else solve_uninterp e_f z )
| Concat {args= ms}, Concat {args= ns} -> ( | Concat {args= ms}, Concat {args= ns} -> (
let siz args = let siz args =
Vector.fold_until args ~init:(integer Z.zero Typ.siz) Vector.fold_until args ~init:(integer Z.zero Typ.siz)

Loading…
Cancel
Save