-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Use IntegralRange
in fgOptimizeCast
#59897
Use IntegralRange
in fgOptimizeCast
#59897
Conversation
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsTo get rid of the duplicated handling, reduce the amount of code and have the CQ benefits that come along. The aforementioned CQ benefits are quite significant: diffs pending. The improvements come mainly from the handling of
|
7c430a2
to
e8e4c90
Compare
It was just forgotten.
Couple good diffs from the handling of GT_CALL.
The comments are right, the code is wrong... Fortunately, the bug was a pessimizing one, not a correctness issue.
And reap the benefits.
e8e4c90
to
d87cc73
Compare
@dotnet/jit-contrib |
Commenter does not have sufficient privileges for PR 59897 in repo dotnet/runtime |
/azp run runtime-coreclr outerloop, runtime-coreclr jitstress |
Azure Pipelines successfully started running 2 pipeline(s). |
var_types srcType = oper->TypeGet(); | ||
var_types dstType = tree->CastToType(); | ||
unsigned dstSize = genTypeSize(dstType); | ||
GenTree* src = cast->CastOp(); |
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.
Are we doing these optimizations even in minopts? Should we be?
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.
Yes we are, that is how it has been for a very long time.
The "discard a cast" part seems low value for minopts, optNarrowTree
, however, does a lot of work for 32 bit targets CQ-wise (notably, it is somewhat misleadingly under a CLFLG_TREETRANS
guard, the only optimization enabled in minopts).
I personally think we should not be doing any optimization in minopts (which then will allow us to selectively enable high-impact optimizations in T0), since it is cheaper to have one big opts.OptimizationEnabled
guard somewhere instead of them being scattered throughout, but disabling this folding will have significant CQ impact, so, it is not something for this change I think. Not to mention there is this complicated tradeoff between folding and TP where high-impact folding may lead to an increase in throughput. I am not sure where fgOptimizeCast
is on that spectrum. I suppose one thing I know from profiles is that it is pretty cheap.
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.
LGTM, much simpler to understand and very nice diffs!
Could lowering or emit check the asserted range for the node and still emit the optimized variant based on that? I'm asking because I hope to understand how to use the asserted ranges in a somewhat similar situation in division by constant lowering. |
Yes, the code here would need to be updated to check for nodes with the range of
Heh... When I was designing Perhaps we should find some similar abstraction for bits, but I am not sure at this point how it would look. |
Summarizing the failures:
|
I wonder if instead of |
I think this is a great suggestion, I will look into implementing it in the next round of |
Thanks again! |
To get rid of the duplicated handling, reduce the amount of code and have the CQ benefits that come along.
The aforementioned CQ benefits are quite significant:
win-x64
,win-arm64
,win-x86
,linux-arm
.The improvements come mainly from the handling of
bool
-returning managed methods, the regressions are due to more aggressive loop inversion, a few register allocation changes and a few lost shortening of instructions (cmp al, 7
->cmp eax, 7
because we no longer have a cast above the call).