-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Morph ASG(ONE_FLD_STRUCT, CALL) using BITCAST
#61049
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
Morph ASG(ONE_FLD_STRUCT, CALL) using BITCAST
#61049
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsLet's see what the CI says about this change. Part of #58312.
|
|
There are diffs with this change:
|
54e2485 to
bdf28d9
Compare
bdf28d9 to
e512f20
Compare
e512f20 to
c72c794
Compare
c72c794 to
931f571
Compare
2f6c81a to
6efc97a
Compare
6efc97a to
5fa597b
Compare
530e6f2 to
f84b512
Compare
5bfcaa8 to
3160e39
Compare
11366bb to
4cc9e1c
Compare
4cc9e1c to
f2b7c58
Compare
6701780 to
16c5773
Compare
16c5773 to
2c0cd3d
Compare
|
This pull request has been automatically marked |
2c0cd3d to
ba64df5
Compare
d4e9ad6 to
b53f19f
Compare
b53f19f to
521071b
Compare
fc6e496 to
dbf12e3
Compare
dbf12e3 to
523a150
Compare
46889ce to
e719865
Compare
24a6eff to
f202ce7
Compare
f202ce7 to
0c46158
Compare
This changes the representation we have for the special case of assignments from calls that return a struct with one field to a promoted local of that struct type, making it more normal and simplifying the model for SSA and value numbering. In the past, the optimization phases treated this case specially and "skipped" the outer struct local in relevant cases. Instead, I propose a new form for this assignment: ASG(FLD, BITCAST(CALL)), that gets rid of this special-casing, and introduces the useful invariant that if a node has an SSA name, then it always represents a def or use of the corresponding SSA local. After optimizations have done their work, lowering removes the new bitcasts as they do not have meaningful value in the backend. There are some downsides to this representation. For example, if we decide to stop retyping helper calls in the importer, VN will start giving BITCAST VNs to locals assigned values produced by important helpers such as TypeHandleToRuntimeTypeHandle. It makes the IR a bit larger, and, perhaps more importantly, more sparse. I can measure a 0.003% increase in memory consumption when CG-ing x64 CoreLib with this change. There are some TP benefits from the reduced checks too, they may offset this regression. It seems to me that the benefits outweigh the drawbacks in this case.
0c46158 to
4974a67
Compare
|
@SingleAccretion, I marked this PR as .NET 8. If you think it should be .NET 7, please let me know. |
This changes the representation we have for the special case of assignments from calls that return a struct with one field
to a promoted local of that struct type, making it more normal and simplifying the model for SSA and value numbering.
In the past, the optimization phases treated this case specially and "skipped" the outer struct local in relevant cases. Instead, I propose a new form for this assignment:
ASG(FLD, BITCAST(CALL)), that gets rid of this special-casing, and introduces the useful invariant that if a node has an SSA name, then it always represents a def or use of the corresponding SSA local.After optimizations have done their work, lowering removes the new bitcasts as they do not have meaningful value in the backend.
There are some downsides to this representation. For example, if we decide to stop retyping helper calls in the importer, VN will start giving BITCAST VNs to locals assigned values produced by important helpers such as
TypeHandleToRuntimeTypeHandle.It makes the IR a bit larger, and, perhaps more importantly, less dense. I can measure a 0.003% increase in memory consumption when CG-ing x64 CoreLib with this change. There are some TP benefits from the reduced checks too, they may offset this regression (my PIN is too noisy to detect anything though :( ).
I posit that the benefits outweigh the drawbacks in this case.
Part of #58312.