s390: Correct bitmasks for bit extraction instructions
Fixes incorrect bitmask generation for s390's RISBG instruction when used for bit extraction with shifts.
This commit corrects an issue on the s390 architecture where the compiler generated incorrect bitmasks for the *extzv_<mode>_{srl,sll}<clobbercc_or_nocc> patterns. These patterns are intended to be implemented by the RISBG instruction, which performs a left rotate. However, the original code did not properly adjust the bitmask to account for the rotated bits, leading to incorrect results when the vacated bits of a shift operation were supposed to be zero. This fix modifies the output templates to use the correct bitmasks, ensuring accurate bit extraction and aligning behavior with the expected zeroing of vacated bits.
In Details
The s390 backend's patterns for bit extraction using shifts, specifically *extzv_<mode>_{srl,sll}<clobbercc_or_nocc>, map to the RISBG instruction. RISBG performs a left rotate, meaning bits shifted out are wrapped around. The original implementation used a fixed bitmask that did not compensate for this rotation when the vacated bits should be zero. For example, (r3 << 1) & 255 was incorrectly generated by RISBG with a bitmask that included the bits rotated from the left. This commit corrects the output templates by adjusting the bitmasks to ensure that only the intended bits are extracte…
- s390
- A family of mainframe computer architectures developed by IBM, used in servers and mainframes.
- RISBG
- Rotate Left, Insert Bit String. A s390 instruction that rotates a value left, inserts a specified bit string, and places the rotated-out bits into vacated positions.
- extzv
- Extract value, zeroing vacated bits. An operation that extracts a sequence of bits from a value and places them into a target, leaving the remaining bits as zero.
- srl
- Shift Right Logical. Shifts bits to the right, filling vacated bits with zeros.
- sll
- Shift Left Logical. Shifts bits to the left, filling vacated bits with zeros.
- clobbercc_or_nocc
- Indicates whether the instruction clobbers (modifies) the condition code registers or not.
- bitmask
- A sequence of bits used to select or manipulate specific bits within another binary value. Operations like ANDing with a bitmask can isolate or clear certain bits.