RFR: 8265491: Math Signum optimization for x86 [v6]

Andrew Haley aph at openjdk.java.net
Fri Apr 23 09:00:37 UTC 2021

On Wed, 21 Apr 2021 17:26:30 GMT, Marcus G K Williams <github.com+168222+mgkwill at openjdk.org> wrote:

>> I am referring to moving the instruction sequence into a macro assembly routine for better code sharing, one should be enough for both float and double type, please refer to following snippet for more detail.
>> https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/x86.ad#L5672
> Hi @jatin-bhateja your original request was quite unclear. The highlighting of the code was incorrect and the use of 'this' made it unclear what you were suggesting and you did not explain a reason for the suggestion. 
>> Can you kindly move **this** into a macro assembly routine.
> Seeing "better code sharing" as the reason it's unclear to me if the proposed refactor results in any meaningful benefit for the work involved. It's also unclear if there are any hard code structure or style issues that would necessitate the move.
> The refactor you suggest calls for the instruction sequences here to be moved into a src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp function that is then called here. Inside that function there is a selection between float and double but otherwise stays the same except one is formatted .AD and one is .CPP/.HPP. 
> If I am doing this refactor for `instruct signumF_reg` and `instruct signumD_reg` to cut down on code duplication, I see that as close to a wash for saving of code lines and effort involved. I also think this would make the code more complex to read.
> However if there are strong opinions as to why this is necessary I'd be happy to hear them.

I think it'd be easier to understand with a signum macro in MacroAssembler. Less code duplication is good, obviously. And it's potentially useful elsewhere. Win-win-win.
We've already factored out C2 instruction sequences for things like vabsnegd  into c2_MacroAssembler_x86.


PR: https://git.openjdk.java.net/jdk/pull/3581

More information about the hotspot-compiler-dev mailing list