diff --git a/src/parse/add_compute.jl b/src/parse/add_compute.jl index 2427ecdf..151cc564 100644 --- a/src/parse/add_compute.jl +++ b/src/parse/add_compute.jl @@ -498,6 +498,14 @@ function add_compute!( end elseif instr.instr === :oftype && length(args) == 2 return get_arg!(ls, args[2], elementbytes, position) + elseif instr.instr === :div_fast && length(args) == 2 && args[1] === 1 + return add_compute!( + ls, + var, + :inv, + [get_arg!(ls, args[2], elementbytes, position)], + elementbytes + ) end vparents = Operation[] deps = Symbol[] @@ -783,7 +791,7 @@ function get_arg!( return xo end elseif x isa Number - return add_constant!(ls, x^p, elementbytes, var)::Operation + return add_constant!(ls, x, elementbytes)::Operation else throw("objects of type $x not supported as arg") end diff --git a/test/simplemisc.jl b/test/simplemisc.jl index b8c850b3..2fd0e60d 100644 --- a/test/simplemisc.jl +++ b/test/simplemisc.jl @@ -33,6 +33,13 @@ function issue480(x, y) end z end + +function issue539!(y, x) + @turbo for i in eachindex(x) + y[i] = 1 / x[i] + end + y +end @testset "issue 480" begin using LoopVectorization x = zeros(33) @@ -44,3 +51,9 @@ end x[i] = 0.0 end end + +@testset "issue 539" begin + x = fill(Inf, 32) + y = similar(x) + @test all(iszero, issue539!(y, x)) +end