AccelerateHS / AccelerateHS/accelerate-llvm

[BUG] Conditional does not gate memory access unless in top-level expression

Abierto
#116 2 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Haskell
Estrellas
171
Forks
65
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.