JuliaSIMD / JuliaSIMD/LoopVectorization.jl
Incorrect result in accumulator expression
- Dominant language
- Julia
- Stars
- 789
- Forks
- 73
- PR merge metrics
- No merged PRs in 30d
Description
Something is causing this third case to be unhappy:
```julia
julia> using LoopVectorization
julia> let a = 1.0, b = 1.0, h = 1.0, v = rand(10)
@avx for i in eachindex(v)
h = a * v[i] + h
end
end
5.877242734755752
julia> let a = 1.0, b = 1.0, h = 1.0, v = rand(10)
@avx for i in eachindex(v)
h = v[i] + b * h
end
end
5.35890841491465
julia> let a = 1.0, b = 1.0, h = 1.0, v = rand(10)
@avx for i in eachindex(v)
h = a * v[i] + b * h
end
end
ERROR: UndefVarError: ##op#602_0 not defined
Stacktrace:
[1] macro expansion at /home/mason/.julia/packages/LoopVectorization/OZUlx/src/reconstruct_loopset.jl:503 [inlined]
[2] _avx_! at /home/mason/.julia/packages/LoopVectorization/OZUlx/src/reconstruct_loopset.jl:503 [inlined]
[3] top-level scope at ./REPL[16]:2
```
Furthermore, if I try to fix it by changing around the syntax, it actually runs and gets an incorrect result:
```julia
julia> let a = 1.5, b = 2.0, h = 3.0, v = rand(10)
@avx for i in eachindex(v)
h_old = h
h = a * v[i] + b * h_old
end
h
end
3.0
julia> let a = 1.5, b = 2.0, h = 3.0, v = rand(10)
for i in eachindex(v)
h_old = h
h = a * v[i] + b * h_old
end
h
end
3979.1681593580383
(@v1.5) pkg> st LoopVectorization
Status `~/.julia/environments/v1.5/Project.toml`
[bdcacae8] LoopVectorization v0.8.24
julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc* (2020-08-01 23:44 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: AMD Ryzen 5 2600 Six-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, znver1)
Environment:
JULIA_NUM_THREADS = 6
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.