The latest System Processor Optimization Primer has this to say (hopefully the indentation will be retained, or at least be self-evident if it isn't):
For most cases (in real life code), the differences between SR/XR vs. LHI or SGR/XGR vs. LGHI will not be noticeable Obtaining the ultimate performance depends on neighboring code, specifically on 1) code address alignment, 2) condition code (CC) dependencies and usage, and 3) register dependencies and usage To expand on the rule of thumb: 1. If one doesn't want to think too hard, use L(G)HI. L(G)HI is generally good as one does not need to worry about register or condition code dependencies. L(G)HI doesn't write the CC, which is a potential plus in terms of processor resource usage. The only downside is its instruction length being a little longer. If someone would want to optimize further, X(G)R or S(G)R can be used instead to relieve instruction fetching limitations which leads to #2 2. If someone wants to think a little more, then the recommendation is to optimize for instruction path-length unless there is a dependency conflict. Thus, * If one is doing a 32/64-bit GR clear and doesn't care about the CC or would prefer the CC to be cleared, use X(G)R or S(G)R * If you're doing a 32/64-bit GR clear and cannot destroy the CC, use L(G)HI * If the GR to be cleared was used near-by (similar to CC concern), use L(G)HI to avoid register dependencies 3. For extreme optimization, one will have to understand the processor pipeline a lot more in terms of instruction grouping, register and condition code buffer size, instruction alignment, etc. * All these considerations can get very complicated and convoluted. So, it is best to leave to the compiler - mb > -----Original Message----- > From: IBM Mainframe Assembler List <ASSEMBLER-LIST@LISTSERV.UGA.EDU> On > Behalf Of Peter Relson > Sent: Thursday, November 16, 2023 10:08 AM > To: ASSEMBLER-LIST@LISTSERV.UGA.EDU > Subject: [EXTERNAL] Re: ASMA057E Undefined operation code SR 15,15 > > Everyone came up with the right alternatives. > > Among XR, SLR, and SR, > XR is thought best (not necessarily measurable better). > > If you don't need a condition code (and certainly if you need to preserve > a condition code), LHI is thought best. > > I'm not sure to what extent the fact that the first three are 2-byte > instructions and LHI is a 4-byte instruction comes into play. It is > apparent that LHI creates a bigger instruction-space footprint. That in > turn can lead to increased cache line usage. > > Peter Relson > z/OS Core Technology Design