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:
@@ -543,10 +543,10 @@ pub(crate) fn emit(
|
|||||||
|
|
||||||
// Here, divisor == -1.
|
// Here, divisor == -1.
|
||||||
if !kind.is_div() {
|
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 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);
|
inst.emit(&[], sink, info, state);
|
||||||
|
|
||||||
let inst = Inst::jmp_known(done_label);
|
let inst = Inst::jmp_known(done_label);
|
||||||
|
|||||||
@@ -142,3 +142,12 @@ block0(v0: i8):
|
|||||||
; run: %srem_imm_i8(-19) == -1
|
; run: %srem_imm_i8(-19) == -1
|
||||||
; run: %srem_imm_i8(0xC0) == -1
|
; run: %srem_imm_i8(0xC0) == -1
|
||||||
; run: %srem_imm_i8(0x80) == -2
|
; 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
|
||||||
|
|||||||
Reference in New Issue
Block a user