RFR: 8336464: C2: Force CastX2P to be a two-address instruction
Fei Gao
fgao at openjdk.org
Mon Aug 5 10:35:34 UTC 2024
On Tue, 30 Jul 2024 17:40:42 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:
> I am not sure about this change. There reason we keep `src `and `dst` in different register for different types is most likely for cases when `src` could be used in other operations. Overwriting `src` register may give you more spills than before.
>
> If there are no other `src` usages RA should handle this I think in shared code.
Thanks for your review @vnkozlov .
In my initial idea, if we keep `src` and `dst` in the same register, when `src` is used in other operations, yes, we need to generate extra spill code like:
Spill src to new_src
CastX2P src src
... // Other operations use new_src
In the final code, we can remove `CastX2P`, it becomes:
mov src new_src
... // Other operations use new_src
If we keep `src` and `dst` in the different registers, we may get:
CastX2P src dst
... // Other operations use src
In the final code, it will be:
mov src dst
... // Other operations use src
I thought that keeping `src` and `dst` might not generate extra `mov`s because we can remove `CastX2P` itself finally.
But I tried some written cases showed in the PR description, which violated my thoughts in an unexpected way. Then I'm also not sure about it.
Anyway, it's a try and comments are welcome :)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20159#issuecomment-2268744405
More information about the hotspot-compiler-dev
mailing list