From e82e8e216c4955db58255062fb5c61c7b2aa3c2a Mon Sep 17 00:00:00 2001 From: Matthieu Sozeau Date: Tue, 13 Feb 2018 18:18:44 +0100 Subject: Better elaboration of pattern-matchings on primitive projections This ensures that computations are shared as much as possible, mimicking the "positive" records computational behavior if possible. --- test-suite/success/letproj.v | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test-suite/success') diff --git a/test-suite/success/letproj.v b/test-suite/success/letproj.v index de2857b43..2f0d8bf8c 100644 --- a/test-suite/success/letproj.v +++ b/test-suite/success/letproj.v @@ -7,3 +7,5 @@ Definition test (A : Type) (f : Foo A) := Scheme foo_case := Case for Foo Sort Type. +Definition test' (A : Type) (f : Foo A) := + let 'Build_Foo _ x y := f in x. -- cgit v1.2.3 From bc103cc493b2127f8a570bcf2e8be94378d79a55 Mon Sep 17 00:00:00 2001 From: Matthieu Sozeau Date: Thu, 8 Mar 2018 12:26:22 -0300 Subject: Add test-suite case for performance, had to use Timeout --- test-suite/success/primitiveproj.v | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test-suite/success') diff --git a/test-suite/success/primitiveproj.v b/test-suite/success/primitiveproj.v index 31a1608c4..7ca2767a5 100644 --- a/test-suite/success/primitiveproj.v +++ b/test-suite/success/primitiveproj.v @@ -199,3 +199,24 @@ split. reflexivity. Qed. *) + +(* Primitive projection match compilation *) +Require Import List. +Set Primitive Projections. + +Record prod (A B : Type) := pair { fst : A ; snd : B }. +Arguments pair {_ _} _ _. + +Fixpoint split_at {A} (l : list A) (n : nat) : prod (list A) (list A) := + match n with + | 0 => pair nil l + | S n => + match l with + | nil => pair nil nil + | x :: l => let 'pair l1 l2 := split_at l n in pair (x :: l1) l2 + end + end. + +Time Eval vm_compute in split_at (repeat 0 20) 10. (* Takes 0s *) +Time Eval vm_compute in split_at (repeat 0 40) 20. (* Takes 0.001s *) +Timeout 1 Time Eval vm_compute in split_at (repeat 0 60) 30. (* Used to take 60s, now takes 0.001s *) -- cgit v1.2.3