269269
270270const IRVar = Union{Core. SSAValue, Core. SlotNumber}
271271
272- function bind_var! (var_literal, bindings:: Bindings , ir:: Core.CodeInfo )
273- # for literal constants
274- push! (bindings, var_literal)
272+ function bind_var! (var, bindings:: Bindings , ir:: Core.CodeInfo )
273+ # for literal constants, and statuc parameter
274+ var = Meta. isexpr (var, :static_parameter ) ? ir. parent. sparam_vals[var. args[1 ]] : var
275+ push! (bindings, var)
275276 idx = length (bindings)
276277 return idx
277278end
@@ -412,12 +413,8 @@ function translate!!(var::IRVar, line::Expr,
412413 bindings:: Bindings , isconst:: Bool , ir:: Core.CodeInfo )
413414 head = line. head
414415 _bind_fn = (x) -> bind_var! (x, bindings, ir)
415- # expand static parameter
416- _expand_sp = (x) -> begin
417- Meta. isexpr (x, :static_parameter ) ? ir. parent. sparam_vals[x. args[1 ]] : x
418- end
419416 if head === :new
420- args = map (_bind_fn ∘ _expand_sp , line. args)
417+ args = map (_bind_fn, line. args)
421418 return Instruction (__new__, args |> Tuple, _bind_fn (var))
422419 elseif head === :call
423420 # Only some of the function calls can be optimized even though many of their results are
@@ -427,7 +424,7 @@ function translate!!(var::IRVar, line::Expr,
427424 v = ir. ssavaluetypes[var. id]. val
428425 _canbeoptimized (v) && return _const_instruction (var, v, bindings, ir)
429426 end
430- args = map (_bind_fn ∘ _expand_sp , line. args)
427+ args = map (_bind_fn, line. args)
431428 # args[1] is the function
432429 func = line. args[1 ]
433430 if Meta. isexpr (func, :static_parameter ) # func is a type parameter
0 commit comments