@@ -4,11 +4,10 @@ Base.:|(u::Unsigned, it::IndexType) = u | UInt8(it)
44Base.:(== )(u:: Unsigned , it:: IndexType ) = (u % UInt8) == UInt8 (it)
55
66function _append_fields! (t:: Expr , body:: Expr , sym:: Symbol , :: Type{T} ) where {T}
7- gf = GlobalRef (Core, :getfield )
87 for f ∈ 1 : fieldcount (T)
98 TF = fieldtype (T, f)
109 Base. issingletontype (TF) && continue
11- gfcall = Expr (:call , gf , sym, f)
10+ gfcall = Expr (:call , getfield , sym, f)
1211 if fieldcount (TF) ≡ 0
1312 push! (t. args, gfcall)
1413 elseif TF <: DataType
3736 body
3837end
3938function rebuild_fields (offset:: Int , :: Type{T} ) where {T}
40- gf = GlobalRef (Core, :getfield )
4139 call = (T <: Tuple ) ? Expr (:tuple ) : Expr (:new , T)
4240 for f ∈ 1 : fieldcount (T)
4341 TF = fieldtype (T, f)
4442 if Base. issingletontype (TF)
4543 push! (call. args, TF. instance)
4644 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 )))
4846 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 ))))
5048 else
5149 arg, offset = rebuild_fields (offset, TF)
5250 push! (call. args, arg)
5856 if Base. issingletontype (T)
5957 return T. instance
6058 elseif fieldcount (T) ≡ 0
61- call = Expr (:call , GlobalRef (Core, : getfield) , :t , 1 , false )
59+ call = Expr (:call , getfield, :t , 1 )
6260 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 ))
6462 else
6563 call, _ = rebuild_fields (0 , T)
6664 end
@@ -377,10 +375,10 @@ val(x) = Expr(:call, Expr(:curly, :Val, x))
377375 quote
378376 $ (Expr (:meta , :inline ))
379377 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))
381379 ptr = gep (p, li)
382380 si = ArrayInterface. StrideIndex {1,$(R[ri],),$(C === 1 ? 1 : 0)} (
383- (getfield (strides (x), $ ri, false ),),
381+ (getfield (strides (x), $ ri),),
384382 (Zero (),),
385383 )
386384 stridedpointer (ptr, si, StaticInt {$(B === 1 ? 1 : 0)} ())
394392 quote
395393 $ (Expr (:meta , :inline ))
396394 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),),
399397 )
400398 stridedpointer (pointer (x), si, StaticInt {$(B == 1 ? 1 : 0)} ())
401399 end
@@ -550,7 +548,7 @@ function add_grouped_strided_pointer!(extra_args::Expr, ls::LoopSet)
550548 push! (gsp. args, val (matcheddims))
551549 gsps = gensym! (ls, " #grouped#strided#pointer#" )
552550 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 )))
554552 preserve, shouldindbyind, roots
555553end
556554
@@ -802,21 +800,10 @@ function generate_call_types(
802800 argmeta = argmeta_and_consts_description (ls, arraysymbolinds)
803801 loop_bounds = loop_boundaries (ls, shouldindbyind)
804802 loop_syms = tuple_expr (QuoteNode, ls. loopsymbols)
805- func = debug ? lv (:_turbo_loopset_debug ) : lv (:_turbo_! )
806803 lbarg = debug ? Expr (:call , :typeof , loop_bounds) : loop_bounds
807804 configarg = (inline, u₁, u₂, v, ls. isbroadcast, thread, warncheckarg, safe)
808805 unroll_param_tup =
809806 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-
820807 add_reassigned_syms! (extra_args, ls) # counterpart to `add_ops!` constants
821808 for (opid, sym) ∈ ls. preamble_symsym # counterpart to process_metadata! symsym extraction
822809 if instruction (ops[opid]) ≠ DROPPEDCONSTANT
@@ -826,17 +813,42 @@ function generate_call_types(
826813 append! (extra_args. args, arraysymbolinds) # add_array_symbols!
827814 add_external_functions! (extra_args, ls) # extract_external_functions!
828815 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
831832 push! (q. args, Expr (:tuple , lbarg, extra_args))
833+ Expr (:block )
832834 else
833835 vargsym = gensym (:vargsym )
834- vecwidthdefq = Expr (:block , Expr (:(= ), vargsym, Expr (:tuple , lbarg, extra_args)))
835836 push! (
836837 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))
839839 )
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)))
840852 end
841853 define_eltype_vec_width! (vecwidthdefq, ls, nothing , true )
842854 push! (vecwidthdefq. args, q)
0 commit comments