Index: llvm/docs/GlobalISel/GenericOpcode.rst =================================================================== --- llvm/docs/GlobalISel/GenericOpcode.rst +++ llvm/docs/GlobalISel/GenericOpcode.rst @@ -254,6 +254,11 @@ G_SBFX sign-extends the result, while G_UBFX zero-extends the result. +If the least-significant bit is larger than the number of bits in the +source, the result is undefined. If the width is zero or if +width minus the least-significant bit is larger than the number of bits +in the source, the result is undefined. + .. code-block:: none ; Extract 5 bits starting at bit 1 from %x and store them in %a. Index: llvm/include/llvm/Target/GenericOpcodes.td =================================================================== --- llvm/include/llvm/Target/GenericOpcodes.td +++ llvm/include/llvm/Target/GenericOpcodes.td @@ -1379,14 +1379,18 @@ // Bitfield extraction. //------------------------------------------------------------------------------ -// Generic signed bitfield extraction. +// Generic signed bitfield extraction. If lsb is larger than the number of +// bits in src, the result is undefined. If width is 0 or width - lsb is +// larger than the number of bits in src, the result is undefined. def G_SBFX : GenericInstruction { let OutOperandList = (outs type0:$dst); let InOperandList = (ins type0:$src, type1:$lsb, type1:$width); let hasSideEffects = false; } -// Generic unsigned bitfield extraction. +// Generic unsigned bitfield extraction. If lsb is larger than the number of +// bits in src, the result is undefined. If width is 0 or width - lsb is +// larger than the number of bits in src, the result is undefined. def G_UBFX : GenericInstruction { let OutOperandList = (outs type0:$dst); let InOperandList = (ins type0:$src, type1:$lsb, type1:$width);