diff --git a/cranelift/filetests/postopt/fold_offset_into_address.clif b/cranelift/filetests/postopt/fold_offset_into_address.clif index 45ce7bcd0a..52379f4a50 100644 --- a/cranelift/filetests/postopt/fold_offset_into_address.clif +++ b/cranelift/filetests/postopt/fold_offset_into_address.clif @@ -16,3 +16,17 @@ ebb0(v0: i64): ; nextln: [RexOp1ldDisp8#808b] v2 = load.i64 notrap aligned v0+16 ; nextln: [Op1ret#c3] return v2 ; nextln: } + +function u0:1(i64, i64 vmctx) { +ebb0(v3: i64, v0: i64): + v1 = iadd_imm.i64 v0, 16 +[RexOp1stDisp8#8089] store.i64 notrap aligned v3, v1 +[Op1ret#c3] return +} + +; sameln: function u0:1(i64, i64 vmctx) fast { +; nextln: ebb0(v3: i64, v0: i64): +; nextln: v1 = iadd_imm v0, 16 +; nextln: [RexOp1stDisp8#8089] store notrap aligned v3, v0+16 +; nextln: [Op1ret#c3] return +; nextln: } diff --git a/lib/codegen/src/postopt.rs b/lib/codegen/src/postopt.rs index 8c64b9bb04..a57497b331 100644 --- a/lib/codegen/src/postopt.rs +++ b/lib/codegen/src/postopt.rs @@ -329,7 +329,7 @@ fn optimize_complex_addresses(pos: &mut EncCursor, inst: Inst, isa: &TargetIsa) .. } => { if let Some(imm) = offset.try_add_i64(imm.into()) { - store_args[0] = arg; + store_args[1] = arg; *offset = imm; } else { // Overflow.