aboutsummaryrefslogtreecommitdiff
path: root/src/Arithmetic/Core.v
diff options
context:
space:
mode:
authorGravatar Jason Gross <jgross@mit.edu>2017-10-15 19:36:25 -0400
committerGravatar Jason Gross <jgross@mit.edu>2017-10-15 21:25:38 -0400
commitff7eaca6315e53e4eae2b75086018a0b5ef70dd6 (patch)
treec665da39b6c90ef5790c023bdec4145ee9e1c548 /src/Arithmetic/Core.v
parent32107e1115481c124cb966c1df6bf3d2c29013cc (diff)
Add faster arithmetic unfolding
Diffstat (limited to 'src/Arithmetic/Core.v')
-rw-r--r--src/Arithmetic/Core.v40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/Arithmetic/Core.v b/src/Arithmetic/Core.v
index 107f8b97f..cf774be57 100644
--- a/src/Arithmetic/Core.v
+++ b/src/Arithmetic/Core.v
@@ -1009,29 +1009,39 @@ Ltac basesystem_partial_evaluation_unfolder t :=
Associational.carry_cps Associational.carry
Associational.negate_snd_cps Associational.negate_snd div modulo
id_tuple_with_alt id_tuple'_with_alt
+ Z.add_get_carry_full
] in t.
-Ltac basesystem_partial_evaluation_RHS_gen unfold_tac :=
- let t := match goal with |- _ _ ?t => t end in
- let t := unfold_tac t in
+Ltac pattern_strip t :=
let t := (eval pattern @Let_In,
- @runtime_mul, @runtime_add, @runtime_opp, @runtime_shr, @runtime_and,
+ @runtime_mul, @runtime_add, @runtime_opp, @runtime_shr, @runtime_and, @runtime_lor,
@id_with_alt,
@Z.add_get_carry, @Z.zselect
in t) in
- let t := match t with ?t _ _ _ _ _ _ _ _ _ => t end in
+ let t := match t with ?t _ _ _ _ _ _ _ _ _ _ => t end in
+ t.
+
+Ltac apply_patterned t1 :=
+ constr:(t1
+ (@Let_In)
+ (@runtime_mul)
+ (@runtime_add)
+ (@runtime_opp)
+ (@runtime_shr)
+ (@runtime_and)
+ (@runtime_lor)
+ (@id_with_alt)
+ (@Z.add_get_carry)
+ (@Z.zselect)).
+
+Ltac basesystem_partial_evaluation_RHS_gen unfold_tac :=
+ let t := match goal with |- _ _ ?t => t end in
+ let t := unfold_tac t in
+ let t := pattern_strip t in
let t1 := fresh "t1" in
pose t as t1;
- transitivity (t1
- (@Let_In)
- (@runtime_mul)
- (@runtime_add)
- (@runtime_opp)
- (@runtime_shr)
- (@runtime_and)
- (@id_with_alt)
- (@Z.add_get_carry)
- (@Z.zselect));
+ let t1' := apply_patterned t1 in
+ transitivity t1';
[replace_with_vm_compute t1; clear t1|reflexivity].
Ltac basesystem_partial_evaluation_default_unfolder t :=