-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Fold some expressions early in importer #80888
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak Issue Detailsnull
|
@dotnet/jit-contrib single-line change, slightly improves TP and mostly negative diffs. TP wins are due to the fact that it now (in some places) removes dead branches earlier than previously and doesn't waste time performing SSA/VN on those, I have a concrete example if you need one. |
src/coreclr/jit/importer.cpp
Outdated
// TODO: we might want to only perform gtFoldExprConst here for TP | ||
op1 = gtFoldExpr(impPopStack().val); | ||
op1 = impPopStack().val; | ||
op1 = opts.OptimizationEnabled() ? gtFoldExpr(op1) : op1; |
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.
Is it worth having a helper impPopStackAndFoldExpr()
?
We can then mark it as forceinline
and have it do the two step thing + relevant optimization checks?
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.
Alternatively, should we just have foldExpr
be a more general part of impPushStack(node)
?
We already do explicit gtFoldExpr
as part of pushing several node types up, but not more generally.
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.
Probably? I assume it needs to be justified in other places as in general it could be a TP regression to run gtFoldExpr where it won't fold anything. But in this place it makes sense to do because BRTRUE/BRFALSE are branches + condition so we potentially remove a branch early
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.
This is similar to what we already do for other branches so seems fine.
Doing this more broadly, as Egor says, may not accomplish much other than make the jit slower. But it's probably worth prototyping.
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.
Nice diffs!
There are small number of minopts diffs, any idea why? |
Most paths in |
That's fine. It makes it a little harder to be confident there are no net minopts diffs, but I suppose it's possible we've been doing opts already we didn't intend to do and so the diffs in the follow-up may be more than just undoing the ones here. |
Exactly - we do it in other places as well, a local experiment demonstrated nice wins for early out in |
No description provided.