cranelift: fix register for srem.i8 on x86_64 (#5540)

* Change register written to in specific srem case. Add regression test as filetest case. Fixes #5470

* Add another test case, newline

* Update comment
This commit is contained in:
Alexa VanHattum
2023-01-06 17:18:16 -05:00
committed by GitHub
parent e65a2c9280
commit 44913825b5
2 changed files with 11 additions and 2 deletions

View File

@@ -543,10 +543,10 @@ pub(crate) fn emit(
// Here, divisor == -1.
if !kind.is_div() {
// x % -1 = 0; put the result into the destination, $rdx.
// x % -1 = 0; put the result into the destination, $rax.
let done_label = sink.get_label();
let inst = Inst::imm(OperandSize::Size64, 0, Writable::from_reg(regs::rdx()));
let inst = Inst::imm(OperandSize::Size64, 0, Writable::from_reg(regs::rax()));
inst.emit(&[], sink, info, state);
let inst = Inst::jmp_known(done_label);

View File

@@ -142,3 +142,12 @@ block0(v0: i8):
; run: %srem_imm_i8(-19) == -1
; run: %srem_imm_i8(0xC0) == -1
; run: %srem_imm_i8(0x80) == -2
function %srem_with_bmask(i64, i8) -> i8 {
block0(v0: i64, v1: i8):
v2 = bmask.i8 v0
v3 = srem v2, v1
return v3
}
; run: %srem_with_bmask(4352, -1) == 0
; run: %srem_with_bmask(4352, 1) == 0