RFR: 8333343: [REDO] AArch64: optimize integer remainder [v3]

Andrew Haley aph at openjdk.org
Thu Jun 6 08:34:46 UTC 2024


On Thu, 6 Jun 2024 07:16:30 GMT, Jin Guojie <duke at openjdk.org> wrote:

>> src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp line 446:
>> 
>>> 444: 
>>> 445:   void msub(Register Rd, Register Rn, Register Rm, Register Ra, Register tmp = rscratch2);
>>> 446:   void msubw(Register Rd, Register Rn, Register Rm, Register Ra, Register tmp = rscratch2);
>> 
>> Please delete these two methods that use rscratch2 as a default tmp register.
>
> I tried it and encountered a problem: msub/msubw will be called in other functions,
> 
>   inline void mnegw(Register Rd, Register Rn, Register Rm) {
>     msubw(Rd, Rn, Rm, zr);
>   }
> 
>   inline void mneg(Register Rd, Register Rn, Register Rm) {
>     msub(Rd, Rn, Rm, zr);
>   }
> 
> If we add a parameter to msub/msubw, then
> 
> 1. All these functions (mnegw, mneg, ...) that call msub/msubw also need to add parameters,
> 
> 2. Moreover, all the calling functions of mnegw and mneg also need to be modified.
> 
> The above two effects involve too many code changes. 
> 
> Please see if we can keep a default parameter for msub/msubw so that their calling functions do not need to be modified.

A hidden clobber of a scratch register makes msub dangerous to use, as the failure of the first version of this PR proved. You don't have to convert 100% of the uses of `msub`, just those that are frequently executed.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19471#discussion_r1629020529


More information about the hotspot-dev mailing list