AccelerateHS / AccelerateHS/accelerate-llvm
[BUG] Conditional does not gate memory access unless in top-level expression
- 主要語言
- Haskell
- 星號
- 171
- 分支
- 65
- PR 合併指標
- 30 天內沒有已合併 PR
描述
To prevent out-of-bounds accesses, conditionals (i.e. `?` operator or `cond`) can be used to check bounds ahead of accessing those arrays. For example the following correctly guards against OOB access:
```
foo = generate (I1 10) $ \(I1 i) ->
i < length bar ? (bar !! i, 0)
```
however, the following does not generate code which correctly guards against OOB access but should:
```
foo = generate (I1 10) $ \(I1 i) ->
T2 (i < length bar ? (bar !! i, 0))
(i < length bar ? ((bar !! i) + 1, 1))
```
This is not an exact reproduction of my scenario but it is similar. Principally what I observer in the generated LLVM output is the `bar` access taking place without first checking if `i < length bar`. This has lead to OOB accesses. When I instead do the following:
```
foo = generate (I1 10) $ \(I1 i) ->
i < length bar ? (T2 (bar !! i) ((bar !! i) + 1), T2 0 1)
```
the OOB access disappears.
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。