Skip to content

Commit 08ebc48

Browse files
committed
eval static parameter when binding vars
1 parent 7cab324 commit 08ebc48

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

.github/workflows/Testing.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
matrix:
1313
version:
1414
- '1.7'
15+
- '1.10'
1516
- '1'
1617
- 'nightly'
1718
os:

src/tapedfunction.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,10 @@ end
269269

270270
const 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
277278
end
@@ -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

Comments
 (0)