aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2016-10-25 17:26:50 +0200
committerXavier Leroy <xavier.leroy@inria.fr>2016-10-25 17:26:50 +0200
commit65ab86a0e3df080ca9a1c37631904d8d02c07596 (patch)
treed7af507348d5329948bd7ca13d362c0341cc555f
parent16e8902f08ed1bf7481a2e7f21b5ebb6c6c81814 (diff)
downloadcompcert-kvx-65ab86a0e3df080ca9a1c37631904d8d02c07596.tar.gz
compcert-kvx-65ab86a0e3df080ca9a1c37631904d8d02c07596.zip
SplitLong: propagate constants through "longofint"
This can make a big difference in which optimizations are triggered later. Constants were already propagated by "longofintu".
-rw-r--r--backend/SplitLong.vp7
-rw-r--r--backend/SplitLongproof.v5
2 files changed, 8 insertions, 4 deletions
diff --git a/backend/SplitLong.vp b/backend/SplitLong.vp
index 60d8e4c4..cbf7fa30 100644
--- a/backend/SplitLong.vp
+++ b/backend/SplitLong.vp
@@ -112,8 +112,11 @@ Definition is_longconst_zero (e: expr) :=
Definition intoflong (e: expr) := lowlong e.
-Definition longofint (e: expr) :=
- Elet e (makelong (shrimm (Eletvar O) (Int.repr 31)) (Eletvar O)).
+Nondetfunction longofint (e: expr) :=
+ match e with
+ | Eop (Ointconst n) Enil => longconst (Int64.repr (Int.signed n))
+ | _ => Elet e (makelong (shrimm (Eletvar O) (Int.repr 31)) (Eletvar O))
+ end.
Definition longofintu (e: expr) :=
makelong (Eop (Ointconst Int.zero) Enil) e.
diff --git a/backend/SplitLongproof.v b/backend/SplitLongproof.v
index 07759dc9..48b8f3d6 100644
--- a/backend/SplitLongproof.v
+++ b/backend/SplitLongproof.v
@@ -362,8 +362,9 @@ Qed.
Theorem eval_longofint: unary_constructor_sound longofint Val.longofint.
Proof.
- red; intros. unfold longofint.
- exploit (eval_shrimm ge sp e m (Int.repr 31) (x :: le) (Eletvar 0)). EvalOp.
+ red; intros. unfold longofint. destruct (longofint_match a).
+- InvEval. econstructor; split. apply eval_longconst. auto.
+- exploit (eval_shrimm ge sp e m (Int.repr 31) (x :: le) (Eletvar 0)). EvalOp.
intros [v1 [A B]].
econstructor; split. EvalOp.
destruct x; simpl; auto.