I have used similar logic to "round up" a length or address value with the same architecturally integral constraints. In this old code fragment GPR 15 contains the initial value to be adjusted. Yes, the code needs to be tweaked for 64-bit values.
I guess if I hurt my head a bit I could use the ROTATE THEN * SELECTED BITS instructions too ! Nifty (perhaps?)! : DBLRND EQU B'111' A double-word length or : * boundary rounding value. : * : LA R14,DBLRND(,0) Load a double-word rounding : * value. : * : ALR R15,R14 Round up the initial value. : * : XR R14,R15 Obtain the rounded sum with : * the rounding bits inverted. : * : NR R15,R14 Obtain the rounded value. Just out of curiosity, are the various Rotate instructions all implemented in hardware on all of the machine models where they exist?