Skip to content

Commit 2e06010

Browse files
authored
Type declarations in mulexpr (#500)
* ignore oftype * support expr in oftype disregard * change tests, storing in 0-dim arrays not supported * mulexpr code_typed is unchanged on Julia master...
1 parent 8fe27b9 commit 2e06010

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/vectorizationbase_compat/contract_pass.jl

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11

2-
mulexprcost(::Number) = 0
3-
mulexprcost(::Symbol) = 1
4-
function mulexprcost(ex::Expr)
5-
base = ex.head === :call ? 10 : 1
6-
base + length(ex.args)
2+
const ProdArg = Union{Symbol,Expr,Number}
3+
function mulexprcost(@nospecialize(x::ProdArg))::Int
4+
if x isa Number
5+
return 0
6+
elseif x isa Symbol
7+
return 1
8+
else
9+
ex = x::Expr
10+
base = ex.head === :call ? 10 : 1
11+
return base + length(ex.args)
12+
end
713
end
8-
function mul_fast_expr(args)
14+
function mul_fast_expr(args::SubArray{Any, 1, Vector{Any}, Tuple{UnitRange{Int64}}, true})::Expr
915
b = Expr(:call, :mul_fast)
1016
for i 2:length(args)
1117
push!(b.args, args[i])
1218
end
1319
b
1420
end
15-
function mulexpr(mulexargs)
16-
a = (mulexargs[1])::Union{Symbol,Expr,Number}
21+
function mulexpr(mulexargs::SubArray{Any, 1, Vector{Any}, Tuple{UnitRange{Int64}}, true})::Tuple{ProdArg,ProdArg}
22+
a = (mulexargs[1])::ProdArg
1723
if length(mulexargs) == 2
18-
return (a, mulexargs[2]::Union{Symbol,Expr,Number})
24+
return (a, mulexargs[2]::ProdArg)
1925
elseif length(mulexargs) == 3
2026
# We'll calc the product between the guesstimated cheaper two args first, for better out of order execution
21-
b = (mulexargs[2])::Union{Symbol,Expr,Number}
22-
c = (mulexargs[3])::Union{Symbol,Expr,Number}
27+
b = (mulexargs[2])::ProdArg
28+
c = (mulexargs[3])::ProdArg
2329
ac = mulexprcost(a)
2430
bc = mulexprcost(b)
2531
cc = mulexprcost(c)

0 commit comments

Comments
 (0)