Skip to content

Commit 946f189

Browse files
committed
unroll for: constant-propagate the counter
1 parent 8ae811b commit 946f189

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/ecMatching.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ module Position = struct
3434
type codepos = (codepos1 * int) list * codepos1
3535
type codeoffset1 = [`ByOffset of int | `ByPosition of codepos1]
3636

37-
let shift ~(offset : int) ((o, p) : codepos1) : codepos1 =
37+
let shift1 ~(offset : int) ((o, p) : codepos1) : codepos1 =
3838
(o + offset, p)
3939

40+
let shift ~(offset : int) ((outp, p) : codepos) : codepos =
41+
(outp, shift1 ~offset p)
42+
4043
let resolve_offset ~(base : codepos1) ~(offset : codeoffset1) : codepos1 =
4144
match offset with
4245
| `ByPosition pos -> pos

src/ecMatching.mli

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ module Position : sig
3030
type codepos = (codepos1 * int) list * codepos1
3131
type codeoffset1 = [`ByOffset of int | `ByPosition of codepos1]
3232

33-
val shift : offset:int -> codepos1 -> codepos1
33+
val shift1 : offset:int -> codepos1 -> codepos1
34+
val shift : offset:int -> codepos -> codepos
35+
3436
val resolve_offset : base:codepos1 -> offset:codeoffset1 -> codepos1
3537
end
3638

src/phl/ecPhlLoopTx.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,14 @@ let process_unroll_for side cpos tc =
317317
[t_apply_hd h'; t_conseq_nm] ] tc
318318
in
319319

320-
let tcenv = t_doit 0 pos zs tc in FApi.t_onalli doi tcenv
320+
let tcenv = t_doit 0 pos zs tc in
321+
let tcenv = FApi.t_onalli doi tcenv in
322+
323+
let cpos = EcMatching.Position.shift ~offset:(-1) cpos in
324+
let clen = blen * (List.length zs - 1) in
325+
326+
Format.eprintf "[W]%d %d@." blen (List.length zs);
327+
FApi.t_last (EcPhlCodeTx.t_cfold side cpos (Some clen)) tcenv
321328

322329
(* -------------------------------------------------------------------- *)
323330
let process_unroll (side, cpos, for_) tc =

tests/cfold.ec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ theory CfoldWhileUnroll.
108108
proc.
109109
cfold 1.
110110
unroll for 2.
111-
cfold 1.
112111
by auto => />.
113112
qed.
114113
end CfoldWhileUnroll.

0 commit comments

Comments
 (0)