Skip to content

Commit 8fe27b9

Browse files
authored
ignore oftype (#497)
* ignore oftype * support expr in oftype disregard * change tests, storing in 0-dim arrays not supported
1 parent ab24678 commit 8fe27b9

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LoopVectorization"
22
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
33
authors = ["Chris Elrod <elrodc@gmail.com>"]
4-
version = "0.12.159"
4+
version = "0.12.160"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/parse/add_compute.jl

+31
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ function add_compute!(
475475
return add_anon_func!(ls, var, fexpr, ex, position, mpref, elementbytes)
476476
# instr = instruction(first(ex.args))::Symbol
477477
instr = instruction!(ls, first(ex.args))::Instruction
478+
478479
args = @view(ex.args[2:end])
479480
if (instr.instr === :pow_fast || instr.instr === :(^)) && length(args) == 2
480481
arg1 = args[1]
@@ -495,6 +496,8 @@ function add_compute!(
495496
arg2num = Int(static(ex.args[3]))::Int
496497
return add_pow!(ls, var, args[1], arg2num, elementbytes, position)
497498
end
499+
elseif instr.instr === :oftype && length(args) == 2
500+
return get_arg!(ls, args[2], elementbytes, position)
498501
end
499502
vparents = Operation[]
500503
deps = Symbol[]
@@ -757,6 +760,34 @@ function add_compute_ifelse!(
757760
)
758761
pushop!(ls, op, LHS)
759762
end
763+
function get_arg!(
764+
ls::LoopSet,
765+
@nospecialize(x),
766+
elementbytes::Int,
767+
position::Int
768+
)::Operation
769+
if x isa Expr
770+
add_operation!(
771+
ls,
772+
Symbol("###xpow###$(length(operations(ls)))###"),
773+
x,
774+
elementbytes,
775+
position
776+
)::Operation
777+
elseif x isa Symbol
778+
if x ls.loopsymbols
779+
add_loopvalue!(ls, x, elementbytes)
780+
else
781+
xo = get(ls.opdict, x, nothing)
782+
xo === nothing && return add_constant!(ls, x, elementbytes)::Operation
783+
return xo
784+
end
785+
elseif x isa Number
786+
return add_constant!(ls, x^p, elementbytes, var)::Operation
787+
else
788+
throw("objects of type $x not supported as arg")
789+
end
790+
end
760791

761792
# adds x ^ (p::Real)
762793
function add_pow!(

test/miscellaneous.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1378,8 +1378,8 @@ end
13781378
axkernel = axes(kernel, 1)
13791379
zout = convert(eltype(out), z)
13801380
for Ipost in Rpost
1381-
for i in axout_tile
1382-
@turbo for Ipre in Rpre
1381+
@turbo for i in axout_tile
1382+
for Ipre in Rpre
13831383
tmp = zout
13841384
# tmp = convert(eltype(out), z) # failing to hoist this leads to an "UndefVarError: tmp not defined"
13851385
for j in axkernel
@@ -1402,8 +1402,8 @@ end
14021402
)
14031403
axkernel = axes(kernel, 1)
14041404
for Ipost in Rpost
1405-
for i in axout_tile
1406-
@turbo for Ipre in Rpre
1405+
@turbo for i in axout_tile
1406+
for Ipre in Rpre
14071407
tmp = zero(eltype(out))
14081408
# tmp = convert(eltype(out), z) # failing to hoist this leads to an "UndefVarError: tmp not defined"
14091409
for j in axkernel

0 commit comments

Comments
 (0)