[llvm-commits] Patch: PPC64 subregister moves

Burke, Max mburke at ea.com
Mon Feb 2 22:16:14 PST 2009


>From PPCRegisterInfo.td, a 64-bit GPR is defined as:

def X1  : GP8< R1,  "r1">, DwarfRegNum<[1]>;

With GP8 being:

class GP8<GPR SubReg, string n> : PPCReg<n> {
  field bits<5> Num = SubReg.Num;
  let SubRegs = [SubReg];
}

So it does look like each 64-bit register has an associated subregister.
Do you foresee this still requiring the RegisterWithSubRegs notation
that you described below? 

Thanks for the SUBREG_TO_REG tip:

  def : Pat<(i64 (zext GPRC:$in)),
-          (RLDICL (OR4To8 GPRC:$in, GPRC:$in), 0, 32)>;
+        (SUBREG_TO_REG (i64 0), GPRC:$in, ppc_subreg_32bit)>;

This cut down the size of the generated code even more!

-Max

-----Original Message-----
From: Dan Gohman [mailto:gohman at apple.com] 
Sent: Monday, February 02, 2009 5:17 PM
To: Commit Messages and Patches for LLVM
Cc: Burke, Max
Subject: Re: [llvm-commits] Patch: PPC64 subregister moves


On Jan 29, 2009, at 11:36 PM, Burke, Max wrote:

> This attempts to reduce the number of emitted OR instructions used to
> move data in and out of subregisters on the PPC64 target. We've  
> noticed
> what looks like many extraneous register moves which in some cases are
> harmless, others which may have unintended, though minor, side effects
> (ie, mr 30, 30 blocking Cell PPE hardware thread at dispatch for 12
> cycles; mr 3, 3 changing the current hardware thread priority to  
> high).
> <ppc64moves.diff>_______________________________________________

I'm not very familiar with PowerPC, but this patch seems like a
reasonably good idea to me. I do have a few comments on it.

In this change:

  def : Pat<(i64 (zext GPRC:$in)),
-          (RLDICL (OR4To8 GPRC:$in, GPRC:$in), 0, 32)>;
+        (RLDICL (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPRC:$in,  
ppc_subreg_32bit), 0, 32)>;

For a zext, if this is really what the hardware provides, this should
use SUBREG_TO_REG with an (i64 0) for the first operand. See how this
is done on x86-64, for example.


In the *RegisterInfo.td file, registers that have subregs should be
declared with RegisterWithSubRegs, instead of just Register. This may
require changing some of the PPC-specific code at the top of the file.

Dan





More information about the llvm-commits mailing list