@@ -4,11 +4,10 @@ Base.:|(u::Unsigned, it::IndexType) = u | UInt8(it)
4
4
Base.:(== )(u:: Unsigned , it:: IndexType ) = (u % UInt8) == UInt8 (it)
5
5
6
6
function _append_fields! (t:: Expr , body:: Expr , sym:: Symbol , :: Type{T} ) where {T}
7
- gf = GlobalRef (Core, :getfield )
8
7
for f ∈ 1 : fieldcount (T)
9
8
TF = fieldtype (T, f)
10
9
Base. issingletontype (TF) && continue
11
- gfcall = Expr (:call , gf , sym, f)
10
+ gfcall = Expr (:call , getfield , sym, f)
12
11
if fieldcount (TF) ≡ 0
13
12
push! (t. args, gfcall)
14
13
elseif TF <: DataType
37
36
body
38
37
end
39
38
function rebuild_fields (offset:: Int , :: Type{T} ) where {T}
40
- gf = GlobalRef (Core, :getfield )
41
39
call = (T <: Tuple ) ? Expr (:tuple ) : Expr (:new , T)
42
40
for f ∈ 1 : fieldcount (T)
43
41
TF = fieldtype (T, f)
44
42
if Base. issingletontype (TF)
45
43
push! (call. args, TF. instance)
46
44
elseif fieldcount (TF) ≡ 0
47
- push! (call. args, Expr (:call , gf , :t , (offset += 1 ), false ))
45
+ push! (call. args, Expr (:call , getfield , :t , (offset += 1 )))
48
46
elseif TF <: DataType
49
- push! (call. args, Expr (:call , lv (:gettype ), Expr (:call , gf , :t , (offset += 1 ), false )))
47
+ push! (call. args, Expr (:call , lv (:gettype ), Expr (:call , getfield , :t , (offset += 1 ))))
50
48
else
51
49
arg, offset = rebuild_fields (offset, TF)
52
50
push! (call. args, arg)
58
56
if Base. issingletontype (T)
59
57
return T. instance
60
58
elseif fieldcount (T) ≡ 0
61
- call = Expr (:call , GlobalRef (Core, : getfield) , :t , 1 , false )
59
+ call = Expr (:call , getfield, :t , 1 )
62
60
elseif T <: DataType
63
- call = Expr (:call , lv (:gettype ), Expr (:call , GlobalRef (Core, : getfield) , :t , 1 , false ))
61
+ call = Expr (:call , lv (:gettype ), Expr (:call , getfield, :t , 1 ))
64
62
else
65
63
call, _ = rebuild_fields (0 , T)
66
64
end
@@ -377,10 +375,10 @@ val(x) = Expr(:call, Expr(:curly, :Val, x))
377
375
quote
378
376
$ (Expr (:meta , :inline ))
379
377
p, li =
380
- VectorizationBase. tdot (x, (vsub_nsw (getfield (i, 1 , false ), one ($ I)),), strides (x))
378
+ VectorizationBase. tdot (x, (vsub_nsw (getfield (i, 1 ), one ($ I)),), strides (x))
381
379
ptr = gep (p, li)
382
380
si = ArrayInterface. StrideIndex {1,$(R[ri],),$(C === 1 ? 1 : 0)} (
383
- (getfield (strides (x), $ ri, false ),),
381
+ (getfield (strides (x), $ ri),),
384
382
(Zero (),),
385
383
)
386
384
stridedpointer (ptr, si, StaticInt {$(B === 1 ? 1 : 0)} ())
394
392
quote
395
393
$ (Expr (:meta , :inline ))
396
394
si = ArrayInterface. StrideIndex {1,$(R[ri],),$(C === 1 ? 1 : 0)} (
397
- (getfield (strides (x), $ ri, false ),),
398
- (getfield (offsets (x), $ ri, false ),),
395
+ (getfield (strides (x), $ ri),),
396
+ (getfield (offsets (x), $ ri),),
399
397
)
400
398
stridedpointer (pointer (x), si, StaticInt {$(B == 1 ? 1 : 0)} ())
401
399
end
@@ -550,7 +548,7 @@ function add_grouped_strided_pointer!(extra_args::Expr, ls::LoopSet)
550
548
push! (gsp. args, val (matcheddims))
551
549
gsps = gensym! (ls, " #grouped#strided#pointer#" )
552
550
push! (extra_args. args, gsps)
553
- pushpreamble! (ls, Expr (:(= ), gsps, Expr (:call , GlobalRef (Core, : getfield) , gsp, 1 )))
551
+ pushpreamble! (ls, Expr (:(= ), gsps, Expr (:call , getfield, gsp, 1 )))
554
552
preserve, shouldindbyind, roots
555
553
end
556
554
@@ -802,21 +800,10 @@ function generate_call_types(
802
800
argmeta = argmeta_and_consts_description (ls, arraysymbolinds)
803
801
loop_bounds = loop_boundaries (ls, shouldindbyind)
804
802
loop_syms = tuple_expr (QuoteNode, ls. loopsymbols)
805
- func = debug ? lv (:_turbo_loopset_debug ) : lv (:_turbo_! )
806
803
lbarg = debug ? Expr (:call , :typeof , loop_bounds) : loop_bounds
807
804
configarg = (inline, u₁, u₂, v, ls. isbroadcast, thread, warncheckarg, safe)
808
805
unroll_param_tup =
809
806
Expr (:call , lv (:avx_config_val ), :(Val {$configarg} ()), VECTORWIDTHSYMBOL)
810
- q = Expr (
811
- :call ,
812
- func,
813
- unroll_param_tup,
814
- val (operation_descriptions),
815
- val (arrayref_descriptions),
816
- val (argmeta),
817
- val (loop_syms),
818
- )
819
-
820
807
add_reassigned_syms! (extra_args, ls) # counterpart to `add_ops!` constants
821
808
for (opid, sym) ∈ ls. preamble_symsym # counterpart to process_metadata! symsym extraction
822
809
if instruction (ops[opid]) ≠ DROPPEDCONSTANT
@@ -826,17 +813,42 @@ function generate_call_types(
826
813
append! (extra_args. args, arraysymbolinds) # add_array_symbols!
827
814
add_external_functions! (extra_args, ls) # extract_external_functions!
828
815
add_outerreduct_types! (extra_args, ls) # extract_outerreduct_types!
829
- if debug
830
- vecwidthdefq = Expr (:block )
816
+ argcestimate = length (extra_args. args) - 1
817
+ for ref = ls. refs_aliasing_syms
818
+ argcestimate += length (ref. loopedindex)
819
+ end
820
+ manyarg = ! debug && (argcestimate > 16 )
821
+ func = debug ? lv (:_turbo_loopset_debug ) : (manyarg ? lv (:_turbo_manyarg! ) : lv (:_turbo_! ))
822
+ q = Expr (
823
+ :call ,
824
+ func,
825
+ unroll_param_tup,
826
+ val (operation_descriptions),
827
+ val (arrayref_descriptions),
828
+ val (argmeta),
829
+ val (loop_syms),
830
+ )
831
+ vecwidthdefq = if debug
831
832
push! (q. args, Expr (:tuple , lbarg, extra_args))
833
+ Expr (:block )
832
834
else
833
835
vargsym = gensym (:vargsym )
834
- vecwidthdefq = Expr (:block , Expr (:(= ), vargsym, Expr (:tuple , lbarg, extra_args)))
835
836
push! (
836
837
q. args,
837
- Expr (:call , GlobalRef (Base, :Val ), Expr (:call , GlobalRef (Base, :typeof ), vargsym)),
838
- Expr (:(... ), Expr (:call , lv (:flatten_to_tuple ), vargsym)),
838
+ Expr (:call , GlobalRef (Base, :Val ), Expr (:call , GlobalRef (Base, :typeof ), vargsym))
839
839
)
840
+ if manyarg
841
+ push! (
842
+ q. args,
843
+ Expr (:call , lv (:flatten_to_tuple ), vargsym),
844
+ )
845
+ else
846
+ push! (
847
+ q. args,
848
+ Expr (:(... ), Expr (:call , lv (:flatten_to_tuple ), vargsym)),
849
+ )
850
+ end
851
+ Expr (:block , Expr (:(= ), vargsym, Expr (:tuple , lbarg, extra_args)))
840
852
end
841
853
define_eltype_vec_width! (vecwidthdefq, ls, nothing , true )
842
854
push! (vecwidthdefq. args, q)
0 commit comments