aarch64 isel: collect_address_addends: correctly handle ExtendOp::UXTW(negative immediate).

The current code doesn't correctly handle the case where `ExtendOp::UXTW` has
as source, a constant-producing insn that produces a negative (32-bit) value.
Then the value is incorrectly sign-extended to 64 bits (in fact, this has
already been done by `ctx.get_constant(insn)`), whereas it needs to be zero
extended.  The obvious fix, done here, is just to force bits 63:32 of the
extension to zero, hence zero-extending it.
This commit is contained in:
Julian Seward
2020-12-04 18:29:39 +01:00
committed by julian-seward1
parent d07fffeb41
commit 8f34d2dc59
2 changed files with 67 additions and 1 deletions

View File

@@ -616,7 +616,7 @@ fn collect_address_addends<C: LowerCtx<I = Inst>>(
maybe_input_insn(ctx, extendee_input, Opcode::Iconst),
extendop,
) {
let value = ctx.get_constant(insn).unwrap() as i64;
let value = (ctx.get_constant(insn).unwrap() & 0xFFFF_FFFF_u64) as i64;
offset += value;
} else {
let reg = put_input_in_reg(ctx, extendee_input, NarrowValueMode::None);