Aarch64: fix shift ops: mask shift amount.
The failure to mask the amount triggered a panic due to a subtraction overflow check; see https://bugzilla.mozilla.org/show_bug.cgi?id=1649432. Attempting to shift by an out-of-range amount should be defined to shift by an amount mod the operand size (i.e., masked to 5 bits for 32-bit shifts, or 6 bits for 64-bit shifts).
This commit is contained in:
@@ -435,8 +435,10 @@ pub(crate) fn put_input_in_rs_immlogic<C: LowerCtx<I = Inst>>(
|
||||
pub(crate) fn put_input_in_reg_immshift<C: LowerCtx<I = Inst>>(
|
||||
ctx: &mut C,
|
||||
input: InsnInput,
|
||||
shift_width_bits: usize,
|
||||
) -> ResultRegImmShift {
|
||||
if let Some(imm_value) = input_to_const(ctx, input) {
|
||||
let imm_value = imm_value & ((shift_width_bits - 1) as u64);
|
||||
if let Some(immshift) = ImmShift::maybe_from_u64(imm_value) {
|
||||
return ResultRegImmShift::ImmShift(immshift);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user