Skip to content

ignore oftype #497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <elrodc@gmail.com>"]
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