> XR over SR seems to be a persistent myth. I have been told again and 
again
> from time to time that XR was faster than SR. There is no reason it 
should
> be, and the evidence is that it is not.

Response from hardware designer:

Here are some thoughts on the best way to zero a register.

First, on the z196 and prior generations, all of the common
instructions for zeroing a register are actually executed in the 
fixed-point execution unit.  Starting with the zEC12 generation 
the following instructions are actually "executed" in the 
register renaming stage of the pipeline (where "R" is the 
same register number for a given instruction):  XR R,R; SR R,R; 
SLR R,R; LA R,0(0,0); LHI R,0 (plus other small constant values); 
LGHI R,0 (plus other small constant values); SGR R,R; SLGR R,R; 
XGR R,R; IIHF R,0; IILF R,0.

On the z196 and earlier processors, since they are actually 
executed, use of an XR or SR may set up an unnecessary register 
dependency.  For example:
....
AL   5,MEM1   Using GR5 for some prior calculation
ST   5,MEM2
...
XR   5,5      This instruction is dependent on the AL
....
So although the XR will zero the register, regardless of its 
prior value, it still appears to be dependent on the AL so 
it can not execute early.

Other points of interest...the XR/SR/SLR are 2-byte 
instructions so they have a smaller instruction footprint, but 
this is a second or third order performance effect in most 
cases.  The IILF/IIHF are 6 byte instructions, so there would 
be little reason to use them.

To conclude, the LHI and LGHI are probably the best overall 
instructions for clearing a register on any generation processor. 
I can not imagine we would ever design a machine where these 
instructions were not at least as fast as XR/SR/SLR for clearing 
a register, and they have some benefits on prior models.


Jim Mulder   z/OS System Test   IBM Corp.  Poughkeepsie,  NY

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to