This patch fixes issue 59074.
In IR or C code, left/right shift amount larger than value size is undefined behavior. But in practise, backend lowering for srl_parts/sra_parts/shl_parts produces add/sub of shift amounts, thus constant shift amounts might be negative or larger than value size. And the lowering depends on behavior in ISA.
PowerPC ISA says, the lowest 7 bits (6 bits if in 32-bit instruction) will be taken, and if the highest among them is 1, result will be zero, otherwise the low 6 bits (or 5 on 32-bit) are used as shift amount.
This patch emulates the behavior and avoids array overflow in bit permutation's value bits calculator.
If I understand correctly, ShiftAmt is unsigned so a "negative value" means very large shift amount here. Can we simply cap ShiftAmt to be no larger than NumBits, and then seems additional boundary checks are not necessary?