J3/10-185r1 To: J3 From: Malcolm Cohen/Stan Whitlock Subject: Bit interp: Maximum value for SHIFT argument. Date: 2010 June 14 ---------------------------------------------------------------------- NUMBER: F08/0035 TITLE: Maximum value for SHIFT argument to SHIFTL and SHIFTR. KEYWORDS: SHIFTL, SHIFTR, BIT_SIZE DEFECT TYPE: Erratum STATUS: J3 consideration in progress QUESTION: A significant part of the justification for the addition of the redundant SHIFTL and SHIFTR intrinsic functions was that in the case of a nonconstant SHIFT argument, the generated code needed to test the shift direction and that such tests were inefficient. However, it is not uncommon for the actual hardware shift instructions to only shift the argument modulo the bit size, for either 32-bit or 64-bit shifts, or both. Since SHIFT is allowed to be equal to the bit size, this means that tests still need to be done to check for this case. Since being able to generate the value zero by shifting an arbitrary nonzero argument completely, applying the feature justification leads one to surmise that perhaps SHIFT should have been limited to BIT_SIZE-1 instead of BIT_SIZE. Q. Should the maximum value of the SHIFT argument to the SHIFTL and SHIFTR intrinsics be BIT_SIZE or BIT_SIZE - 1? Note: A similar argument does not apply quite so straightforwardly to SHIFTA, since it provides new functionality. ANSWER: A. Although allowing SHIFTL and SHIFTR by BIT_SIZE provides little useful functionality, this is allowed for consistency with ISHFT. ALTERNATIVE ANSWER: A. Yes, the SHIFT argument should have been limited to BIT_SIZE - 1; an edit is supplied to correct this. EDITS to 10-007: None. ALTERNATIVE EDITS: [387:7,16] Delete "or equal to". SUBMITTED BY: Malcolm Cohen HISTORY: 10-185 m192 F08/0035 submitted 10-185r1 m192 Draft answer with staw vote alternative ----------------------------------------------------------------------