-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slightly generalize _compute_sparam elision #48144
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -796,7 +796,6 @@ end | |||||||||||||||||||||||||
end && return nothing | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
arg = sig.parameters[i] | ||||||||||||||||||||||||||
isa(arg, DataType) || return nothing | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
rarg = def.args[2 + i] | ||||||||||||||||||||||||||
isa(rarg, SSAValue) || return nothing | ||||||||||||||||||||||||||
|
@@ -805,6 +804,10 @@ end | |||||||||||||||||||||||||
rarg = argdef.args[1] | ||||||||||||||||||||||||||
isa(rarg, SSAValue) || return nothing | ||||||||||||||||||||||||||
argdef = compact[rarg][:inst] | ||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||
isa(arg, DataType) || return nothing | ||||||||||||||||||||||||||
isType(arg) || return nothing | ||||||||||||||||||||||||||
arg = arg.parameters[1] | ||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
is_known_call(argdef, Core.apply_type, compact) || return nothing | ||||||||||||||||||||||||||
|
@@ -815,15 +818,23 @@ end | |||||||||||||||||||||||||
applyT = applyT.val | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
isa(applyT, UnionAll) || return nothing | ||||||||||||||||||||||||||
# N.B.: At the moment we only lift the valI == 1 case, so we | ||||||||||||||||||||||||||
# only need to look at the outermost tvar. | ||||||||||||||||||||||||||
applyTvar = applyT.var | ||||||||||||||||||||||||||
applyTbody = applyT.body | ||||||||||||||||||||||||||
Keno marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
isa(applyTbody, DataType) || return nothing | ||||||||||||||||||||||||||
applyTbody.name == arg.name || return nothing | ||||||||||||||||||||||||||
length(applyTbody.parameters) == length(arg.parameters) == 1 || return nothing | ||||||||||||||||||||||||||
applyTbody.parameters[1] === applyTvar || return nothing | ||||||||||||||||||||||||||
arg.parameters[1] === tvar || return nothing | ||||||||||||||||||||||||||
return LiftedValue(argdef.args[3]) | ||||||||||||||||||||||||||
arg = unwrap_unionall(arg) | ||||||||||||||||||||||||||
applyTbody = unwrap_unionall(applyTbody) | ||||||||||||||||||||||||||
Keno marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
(isa(arg, DataType) && isa(applyTbody, DataType)) || return nothing | ||||||||||||||||||||||||||
applyTbody.name === arg.name || return nothing | ||||||||||||||||||||||||||
length(applyTbody.parameters) == length(arg.parameters) || return nothing | ||||||||||||||||||||||||||
for i = 1:length(applyTbody.parameters) | ||||||||||||||||||||||||||
if applyTbody.parameters[i] === applyTvar && arg.parameters[i] === tvar | ||||||||||||||||||||||||||
return LiftedValue(argdef.args[3]) | ||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||
Comment on lines
+831
to
+836
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it it may be clearer (and more extensible later) if written this way:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure whether we want to look at all the parameters or just the first one. We can probably look at the first one in applyTbody, but I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First is indeed probably the most common to extract |
||||||||||||||||||||||||||
return nothing | ||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# NOTE we use `IdSet{Int}` instead of `BitSet` for in these passes since they work on IR after inlining, | ||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isType(x)
includesisa(x, DataType)
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do in a follow up