Skip to content

Commit

Permalink
Fix #2058.
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Dec 8, 2023
1 parent bd908da commit 730f7b0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

* Futhark's LSP server should work better with Eglot.

* Incorrect copy removal inside histograms could cause compiler error
(#2058).

## [0.25.9]

### Added
Expand Down
14 changes: 7 additions & 7 deletions src/Futhark/IR/SegOp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,8 +1157,8 @@ simplifySegOp (SegScan lvl space scans ts kbody) = do
simplifySegOp (SegHist lvl space ops ts kbody) = do
(lvl', space', ts') <- Engine.simplify (lvl, space, ts)

(ops', ops_hoisted) <- fmap unzip $
forM ops $
Engine.localVtable (flip (foldr ST.consume) $ concatMap histDest ops) $ do
(ops', ops_hoisted) <- fmap unzip . forM ops $
\(HistOp w rf arrs nes dims lam) -> do
w' <- Engine.simplify w
rf' <- Engine.simplify rf
Expand All @@ -1174,12 +1174,12 @@ simplifySegOp (SegHist lvl space ops ts kbody) = do
op_hoisted
)

(kbody', body_hoisted) <- simplifyKernelBody space kbody
(kbody', body_hoisted) <- simplifyKernelBody space kbody

pure
( SegHist lvl' space' ops' ts' kbody',
mconcat ops_hoisted <> body_hoisted
)
pure
( SegHist lvl' space' ops' ts' kbody',
mconcat ops_hoisted <> body_hoisted
)
where
scope = scopeOfSegSpace space
scope_vtable = ST.fromScope scope
Expand Down
5 changes: 5 additions & 0 deletions tests/issue2058.fut
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- We neglected to mark the target arrays as consumed while
-- simplifying the body.

entry problem [n] (arr: *[n]i64) : [n]i64 =
reduce_by_index arr (+) 0 (iota n) (copy arr)

0 comments on commit 730f7b0

Please sign in to comment.