Skip to content

Commit b2ed6f5

Browse files
Gustavo2622strub
authored andcommitted
Refactor cfold propagation and add eager mode
Refactor `cfold` in `ecPhlCodeTx` to track propagated substitutions and preserved dependencies explicitly, and use that state to decide when folding can continue across assignments and structured instructions. Add an eager `cfold*` variant that keeps folding by promoting preserved variables into the propagated substitution when possible, and extend `tests/cfold.ec` with coverage for both the default and eager behaviors.
1 parent cc03b30 commit b2ed6f5

7 files changed

Lines changed: 309 additions & 111 deletions

File tree

src/ecPV.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ module PVMap = struct
4747
Mnpv.find_opt (pvm m.pvm_env k) m.pvm_map
4848

4949
let raw m = m.pvm_map
50+
5051
end
5152

5253
(* -------------------------------------------------------------------- *)

src/ecParser.mly

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2991,7 +2991,10 @@ interleave_info:
29912991
{ Pinterleave info }
29922992

29932993
| CFOLD s=side? c=codepos n=word?
2994-
{ Pcfold (s, c, n) }
2994+
{ Pcfold (s, c, n, false) }
2995+
2996+
| CFOLD STAR s=side? c=codepos n=word?
2997+
{ Pcfold (s, c, n, true) }
29952998

29962999
| RND s=side? info=rnd_info c=prefix(COLON, semrndpos)?
29973000
{ Prnd (s, c, info) }

src/ecParsetree.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ type phltactic =
757757
| Pcond of pcond_info
758758
| Pmatch of matchmode
759759
| Pswap of ((oside * pswap_kind) located list)
760-
| Pcfold of (oside * pcodepos * int option)
760+
| Pcfold of (oside * pcodepos * int option * bool) (* side + 1st inst + n lines + eager? *)
761761
| Pinline of inline_info
762762
| Poutline of outline_info
763763
| Pinterleave of interleave_info located

0 commit comments

Comments
 (0)