Skip to content

Commit 5482caf

Browse files
committed
recurse into GotoIfNot as well
1 parent 09eb415 commit 5482caf

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

base/meta.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,14 @@ function _partially_inline!(@nospecialize(x), slot_replacements::Vector{Any},
347347
if isa(x, Core.ReturnNode)
348348
return Core.ReturnNode(
349349
_partially_inline!(x.val, slot_replacements, type_signature, static_param_values,
350-
slot_offset, statement_offset, boundscheck)
350+
slot_offset, statement_offset, boundscheck),
351+
)
352+
end
353+
if isa(x, Core.GotoIfNot)
354+
return Core.GotoIfNot(
355+
_partially_inline!(x.cond, slot_replacements, type_signature, static_param_values,
356+
slot_offset, statement_offset, boundscheck),
357+
x.dest,
351358
)
352359
end
353360
if isa(x, Expr)

test/meta.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,8 @@ f(::T) where {T} = T
238238
ci = code_lowered(f, Tuple{Int})[1]
239239
@test Meta.partially_inline!(ci.code, [], Tuple{typeof(f),Int}, Any[Int], 0, 0, :propagate) ==
240240
Any[Core.ReturnNode(QuoteNode(Int))]
241+
242+
g(::Val{x}) where {x} = x ? 1 : 0
243+
ci = code_lowered(g, Tuple{Val{true}})[1]
244+
@test Meta.partially_inline!(ci.code, [], Tuple{typeof(g),Val{true}}, Any[Val{true}], 0, 0, :propagate)[1] ==
245+
Core.GotoIfNot(QuoteNode(Val{true}), 3)

0 commit comments

Comments
 (0)