Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
athas authored and CKuke committed Nov 8, 2023
1 parent 62db6fb commit 4c7d8b4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

* Very large `iota`s now work.

* Lambda lifting in `while` conditions (#2038).

## [0.25.6]

### Added
Expand Down
7 changes: 4 additions & 3 deletions src/Futhark/Internalise/LiftLambdas.hs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,10 @@ transformExp (AppExp (Match e cases loc) appres) = do
<*> pure case_loc
transformExp (AppExp (Loop sizes pat args form body loc) appres) = do
args' <- transformExp args
form' <- astMap transformSubExps form
body' <- bindingParams sizes [pat] $ bindingForm form' $ transformExp body
pure $ AppExp (Loop sizes pat args' form' body' loc) appres
bindingParams sizes [pat] $ do
form' <- astMap transformSubExps form
body' <- bindingForm form' $ transformExp body
pure $ AppExp (Loop sizes pat args' form' body' loc) appres
transformExp e@(Var v _ _) =
-- Note that function-typed variables can only occur in expressions,
-- not in other places where VNames/QualNames can occur.
Expand Down
4 changes: 2 additions & 2 deletions src/Language/Futhark/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ prettyAppExp _ (Loop sizeparams pat initexp form loopbody _) =
( hsep (map (brackets . prettyName) sizeparams ++ [pretty pat])
<+> equals
<+> pretty initexp
<+> pretty form
<+> "do"
</> pretty form
</> "do"
)
</> indent 2 (pretty loopbody)
prettyAppExp _ (Index e idxs _) =
Expand Down
11 changes: 11 additions & 0 deletions tests/issue2038.fut
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
entry all_work_indices (n:i64) (m:i64) =
let block i prog prog' =
(i, prog, i64.max 0 (i64.min (n-i) (if i == 0 then n else prog')))
let size (_, a, b) = b-a >> 1
let (iter, _) = loop (iter, progress) = (0, replicate m 0)
while not (all id (tabulate m (\i -> progress[i] >= n-i-1))) do
let blockrow = map3 block
(iota m) (progress) (rotate (-1) progress)
let sizes = map size blockrow
in (iter + 1i32, map2 (+) progress sizes)
in iter

0 comments on commit 4c7d8b4

Please sign in to comment.