RFR: JDK-8331732 : [PPC64] Unify and optimize code which converts != 0 to 1 [v2]

Martin Doerr mdoerr at openjdk.org
Thu Jun 27 16:42:15 UTC 2024


On Thu, 27 Jun 2024 08:05:55 GMT, Suchismith Roy <sroy at openjdk.org> wrote:

>> src/hotspot/cpu/ppc/macroAssembler_ppc.cpp line 356:
>> 
>>> 354:     else
>>> 355:       cmpwi(CCR0, dst, 0);
>>> 356:     setbcr(dst, CCR0, Assembler::zero);
>> 
>> This is what I understood after implementation & definition: 
>> 
>> If bit BI of the CR contains a 1, register RT is set to 0. Otherwise, register RT is set to 1.
>> 
>> CCR0 will contain `1` when `dst == 0`. then  `dst` will be set to `1` by `setbcr`.
>
> Yes the bit related to value of zero will be set. and setbcr will return  0 , if value is 1 in the CCR0. So the return register will have a value of 0, since it is 0. Similarly for non zero value, setbcr will return 1, and return register will have value of 1, which is the expected behaviour.

I'd prefer using `Assembler::equal` because we have compared with 0 before. Also, please add curly braces.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19886#discussion_r1657453959


More information about the hotspot-dev mailing list