Debian Codegraph @

tests/memory-block-merging/coalescing/safety-condition-3/neg0.fut

raw
1 -- Negative test. 'xs' is used while 'ys' is live, so we cannot merge their
2 -- memory blocks, since 'zs' would then map over the contents of 'ys' instead of
3 -- the original contents of 'xs[i]'.
4 -- ==
5 -- input { [[2, 2],
6 -- [2, 2]]
7 -- [3, 4]
8 -- 1i64
9 -- }
10 -- output { [[2, 2],
11 -- [4, 5]]
12 -- 6
13 -- }
14 -- structure seq-mem { Alloc 2 }
15 -- structure gpu-mem { Alloc 3 }
16
17 let main [n] (xs: *[n][n]i32) (ys0: [n]i32) (i: i64): ([n][n]i32, i32) =
18 let ys = map (+ 1) ys0
19 let zs = map (+ ys[0]) xs[i] -- Cannot be hoisted to exist before 'ys', which
20 -- would have solved the problem.
21 let xs[i] = ys
22 in (xs, zs[i])