Skip to content

Commit

Permalink
ignore oftype (#497)
Browse files Browse the repository at this point in the history
* ignore oftype

* support expr in oftype disregard

* change tests, storing in 0-dim arrays not supported
  • Loading branch information
chriselrod authored May 22, 2023
1 parent ab24678 commit 8fe27b9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LoopVectorization"
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
authors = ["Chris Elrod <[email protected]>"]
version = "0.12.159"
version = "0.12.160"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
31 changes: 31 additions & 0 deletions src/parse/add_compute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ function add_compute!(
return add_anon_func!(ls, var, fexpr, ex, position, mpref, elementbytes)
# instr = instruction(first(ex.args))::Symbol
instr = instruction!(ls, first(ex.args))::Instruction

args = @view(ex.args[2:end])
if (instr.instr === :pow_fast || instr.instr === :(^)) && length(args) == 2
arg1 = args[1]
Expand All @@ -495,6 +496,8 @@ function add_compute!(
arg2num = Int(static(ex.args[3]))::Int
return add_pow!(ls, var, args[1], arg2num, elementbytes, position)
end
elseif instr.instr === :oftype && length(args) == 2
return get_arg!(ls, args[2], elementbytes, position)
end
vparents = Operation[]
deps = Symbol[]
Expand Down Expand Up @@ -757,6 +760,34 @@ function add_compute_ifelse!(
)
pushop!(ls, op, LHS)
end
function get_arg!(
ls::LoopSet,
@nospecialize(x),
elementbytes::Int,
position::Int
)::Operation
if x isa Expr
add_operation!(
ls,
Symbol("###xpow###$(length(operations(ls)))###"),
x,
elementbytes,
position
)::Operation
elseif x isa Symbol
if x ls.loopsymbols
add_loopvalue!(ls, x, elementbytes)
else
xo = get(ls.opdict, x, nothing)
xo === nothing && return add_constant!(ls, x, elementbytes)::Operation
return xo
end
elseif x isa Number
return add_constant!(ls, x^p, elementbytes, var)::Operation
else
throw("objects of type $x not supported as arg")
end
end

# adds x ^ (p::Real)
function add_pow!(
Expand Down
8 changes: 4 additions & 4 deletions test/miscellaneous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1378,8 +1378,8 @@ end
axkernel = axes(kernel, 1)
zout = convert(eltype(out), z)
for Ipost in Rpost
for i in axout_tile
@turbo for Ipre in Rpre
@turbo for i in axout_tile
for Ipre in Rpre
tmp = zout
# tmp = convert(eltype(out), z) # failing to hoist this leads to an "UndefVarError: tmp not defined"
for j in axkernel
Expand All @@ -1402,8 +1402,8 @@ end
)
axkernel = axes(kernel, 1)
for Ipost in Rpost
for i in axout_tile
@turbo for Ipre in Rpre
@turbo for i in axout_tile
for Ipre in Rpre
tmp = zero(eltype(out))
# tmp = convert(eltype(out), z) # failing to hoist this leads to an "UndefVarError: tmp not defined"
for j in axkernel
Expand Down

0 comments on commit 8fe27b9

Please sign in to comment.