Skip to content

Commit

Permalink
Fix #1126.
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Sep 13, 2020
1 parent cc7538f commit a0746fa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Futhark/Optimise/TileLoops.hs
Expand Up @@ -113,7 +113,7 @@ tileInBody branch_variant private initial_variance initial_lvl initial_space res
not $ gtid `nameIn` branch_variant,
(prestms', poststms') <-
preludeToPostlude variance prestms stm_to_tile (stmsFromList poststms),
used <- freeIn stm_to_tile <> freeIn stms_res =
used <- freeIn stm_to_tile <> freeIn poststms' <> freeIn stms_res =
Just . injectPrelude initial_space private variance prestms' used
<$> tileGeneric
(tiling1d $ reverse top_space_rev)
Expand All @@ -135,7 +135,7 @@ tileInBody branch_variant private initial_variance initial_lvl initial_space res
kdim_y : kdim_x : top_kdims_rev <- reverse kdims,
(prestms', poststms') <-
preludeToPostlude variance prestms stm_to_tile (stmsFromList poststms),
used <- freeIn stm_to_tile <> freeIn stms_res =
used <- freeIn stm_to_tile <> freeIn poststms' <> freeIn stms_res =
Just . injectPrelude initial_space private variance prestms' used
<$> tileGeneric
(tiling2d $ reverse $ zip top_gtids_rev top_kdims_rev)
Expand Down
16 changes: 16 additions & 0 deletions tests/tiling/tricky_prelude0.fut
@@ -0,0 +1,16 @@
-- A case of tiling with a complex dependency.
-- ==
-- compiled random input { [100]i32 } auto output
-- structure distributed { SegMap/DoLoop/SegMap 2 }

let main (xs: []i32) =
map (\x ->
let y = x + 2 -- Used in postlude.
let z = loop z=0 while z < 1337 do z * 2 + y -- Uses 'y', but
-- cannot itself
-- be inlined in
-- the postlude.
let loopres = #[sequential] i32.sum (map (+z) xs) -- Uses z.
in loopres + i32.clz y -- 'y' must be made available here.
)
xs

0 comments on commit a0746fa

Please sign in to comment.