When does C1 use the same register for inputs and temps?

Andrew Haley aph-open at littlepinkcloud.com
Thu Feb 20 11:38:00 UTC 2025


Sometimes C1 allocates the same register for inputs and temps.
There are several workarounds in the back ends for this.

For example, here in x86 LIR_Assembler::emit_typecheck_helper:

   Register obj = op->object()->as_register();
   Register k_RInfo = op->tmp1()->as_register();
   ...
   if (obj == k_RInfo) {
     k_RInfo = dst;
   } else if (obj == klass_RInfo) {
     klass_RInfo = dst;
   }

Is it simply that if you want an input reg not to be reused for a temp,
then you should call do_temp() as well as do_input() on the input arg,
as is done in LIR_Op2? But if that is the case, would it not have been
better always to call do_temp() as well as do_input() on
opTypeCheck->_object, thus avoiding the code I quoted above?

Was it simply that way back when, people were trying to use the absolute
minimum of registers?

Thanks,

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



More information about the hotspot-compiler-dev mailing list