diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-10-09 14:17:30 +0200 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-10-09 14:17:30 +0200 |
commit | 0372472c17ceac36765c8921548672503115bb04 (patch) | |
tree | 6fc6f7a4dba45e1ec993c688be446c9527a44098 /kvx/SelectOp.vp | |
parent | a66650006bd85a196d4a986ad36ee265d57b828c (diff) | |
download | compcert-kvx-0372472c17ceac36765c8921548672503115bb04.tar.gz compcert-kvx-0372472c17ceac36765c8921548672503115bb04.zip |
do not synthesize select if both operands are identical
Diffstat (limited to 'kvx/SelectOp.vp')
-rw-r--r-- | kvx/SelectOp.vp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/kvx/SelectOp.vp b/kvx/SelectOp.vp index 9e5d45a0..65dba3ac 100644 --- a/kvx/SelectOp.vp +++ b/kvx/SelectOp.vp @@ -103,8 +103,14 @@ Nondetfunction select0 (ty : typ) (cond0 : condition0) (e1 e2 e3: expr) := | _, _, _ => (Eop (Osel cond0 ty) (e1 ::: e2 ::: e3 ::: Enil)) end. +Definition same_expr_pure (e1 e2: expr) := + match e1, e2 with + | Evar v1, Evar v2 => if ident_eq v1 v2 then true else false + | _, _ => false + end. + Definition select (ty : typ) (cond : condition) (args : exprlist) (e1 e2: expr) : option expr := - Some( + Some (if same_expr_pure e1 e2 then e1 else match cond_to_condition0 cond args with | None => select0 ty (Ccomp0 Cne) e1 e2 (Eop (Ocmp cond) args) | Some(cond0, ec) => select0 ty cond0 e1 e2 ec @@ -356,12 +362,6 @@ Nondetfunction orimm (n1: int) (e2: expr) := | _ => Eop (Oorimm n1) (e2:::Enil) end. -Definition same_expr_pure (e1 e2: expr) := - match e1, e2 with - | Evar v1, Evar v2 => if ident_eq v1 v2 then true else false - | _, _ => false - end. - Nondetfunction or (e1: expr) (e2: expr) := match e1, e2 with | Eop (Ointconst n1) Enil, t2 => orimm n1 t2 |