Redundant Array Removal is too Strict with Storage
- Dominant language
- Python
- Stars
- 593
- Forks
- 163
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 60
Description
Consider the following SDFG

where `a` is copied into `t` then into `p` and finally into `b`.
One would expect that simplify (`RedundantArrayRemoval` in particular) could remove these copies.
However, this is only the case if `t` and `p` have the same storage type, since those are transients, one should expect that DaCe would do this.
However, if `p` is a register, as it is below in the code, then `p` is maintained.
Furthermore, we the subsets would be changed to `0:80` for example, then it would also not work.
```
import dace
sdfg = dace.SDFG("test")
state = sdfg.add_state(is_start_block=True)
sdfg.add_array(
"a",
shape=(100,),
transient=False,
dtype=dace.float64,
)
sdfg.add_array(
"t",
shape=(100,),
transient=True,
dtype=dace.float64,
)
sdfg.add_array(
"p",
shape=(100,),
transient=True,
dtype=dace.float64,
# If `p` is a register, it can not be optimized away
# but if it is, then it can be removed.
storage=dace.StorageType.Register,
)
sdfg.add_array(
"b",
shape=(100,),
transient=False,
dtype=dace.float64,
)
a, t, p, b = (state.add_access(n) for n in "atpb")
state.add_nedge(
a,
t,
dace.Memlet("a[0:100] -> [0:100]"),
)
state.add_nedge(
t,
p,
dace.Memlet("t[0:100] -> [0:100]"),
)
state.add_nedge(
p,
b,
dace.Memlet("p[0:100] -> [0:100]"),
)
sdfg.validate()
sdfg.simplify()
sdfg.validate()
```
Contributor guide
Assessment
This issue has not been assessed yet.