Skip to content

Commit f2e5264

Browse files
committed
inference: don't add backedge when applicable inferred to return Bool
As a minor backedge reduction optimization, this commit avoids adding backedges when `applicable` is inferred to return `::Bool`.
1 parent b38fde1 commit f2e5264

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

base/compiler/tfuncs.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,14 +3008,16 @@ function abstract_applicable(interp::AbstractInterpreter, argtypes::Vector{Any},
30083008
else
30093009
rt = Const(true) # has applicable matches
30103010
end
3011-
for i in 1:napplicable
3012-
match = applicable[i]::MethodMatch
3013-
edge = specialize_method(match)::MethodInstance
3014-
add_backedge!(sv, edge)
3015-
end
3016-
# also need an edge to the method table in case something gets
3017-
# added that did not intersect with any existing method
3018-
add_uncovered_edges!(sv, matches, atype)
3011+
if rt !== Bool
3012+
for i in 1:napplicable
3013+
match = applicable[i]::MethodMatch
3014+
edge = specialize_method(match)
3015+
add_backedge!(sv, edge)
3016+
end
3017+
# also need an edge to the method table in case something gets
3018+
# added that did not intersect with any existing method
3019+
add_uncovered_edges!(sv, matches, atype)
3020+
end
30193021
end
30203022
return Future(CallMeta(rt, Union{}, EFFECTS_TOTAL, NoCallInfo()))
30213023
end

0 commit comments

Comments
 (0)