Codegen fix atomic_cas with samll types on riscv64 (#5919)
* fix issue5901 * add regression test file. * fix regression targets. * fix a comment. * enable atomic-cas-little for riscv64 * specify little endian some s390x can pass test. * fix register error
This commit is contained in:
@@ -1511,7 +1511,7 @@ impl AtomicOP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// like extract but sign extend the value.
|
/// like extract but sign extend the value.
|
||||||
/// suitable for smax.
|
/// suitable for smax,etc.
|
||||||
pub(crate) fn extract_sext(
|
pub(crate) fn extract_sext(
|
||||||
rd: WritableReg,
|
rd: WritableReg,
|
||||||
offset: Reg,
|
offset: Reg,
|
||||||
|
|||||||
@@ -1275,31 +1275,27 @@ impl MachInstEmit for Inst {
|
|||||||
amo: AMO::SeqCst,
|
amo: AMO::SeqCst,
|
||||||
}
|
}
|
||||||
.emit(&[], sink, emit_info, state);
|
.emit(&[], sink, emit_info, state);
|
||||||
let origin_value = if ty.bits() < 32 {
|
if ty.bits() < 32 {
|
||||||
AtomicOP::extract(t0, offset, dst.to_reg(), ty)
|
AtomicOP::extract(dst, offset, dst.to_reg(), ty)
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|i| i.emit(&[], sink, emit_info, state));
|
.for_each(|i| i.emit(&[], sink, emit_info, state));
|
||||||
t0.to_reg()
|
|
||||||
} else if ty.bits() == 32 {
|
} else if ty.bits() == 32 {
|
||||||
Inst::Extend {
|
Inst::Extend {
|
||||||
rd: t0,
|
rd: dst,
|
||||||
rn: dst.to_reg(),
|
rn: dst.to_reg(),
|
||||||
signed: false,
|
signed: false,
|
||||||
from_bits: 32,
|
from_bits: 32,
|
||||||
to_bits: 64,
|
to_bits: 64,
|
||||||
}
|
}
|
||||||
.emit(&[], sink, emit_info, state);
|
.emit(&[], sink, emit_info, state);
|
||||||
t0.to_reg()
|
}
|
||||||
} else {
|
|
||||||
dst.to_reg()
|
|
||||||
};
|
|
||||||
Inst::CondBr {
|
Inst::CondBr {
|
||||||
taken: BranchTarget::Label(fail_label),
|
taken: BranchTarget::Label(fail_label),
|
||||||
not_taken: BranchTarget::zero(),
|
not_taken: BranchTarget::zero(),
|
||||||
kind: IntegerCompare {
|
kind: IntegerCompare {
|
||||||
kind: IntCC::NotEqual,
|
kind: IntCC::NotEqual,
|
||||||
rs1: e,
|
rs1: e,
|
||||||
rs2: origin_value,
|
rs2: dst.to_reg(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
.emit(&[], sink, emit_info, state);
|
.emit(&[], sink, emit_info, state);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
test interpret
|
test interpret
|
||||||
test run
|
test run
|
||||||
target s390x
|
target s390x
|
||||||
|
target riscv64 has_a
|
||||||
|
|
||||||
; We can't test that these instructions are right regarding atomicity, but we can
|
; We can't test that these instructions are right regarding atomicity, but we can
|
||||||
; test if they perform their operation correctly
|
; test if they perform their operation correctly
|
||||||
|
|||||||
21
cranelift/filetests/filetests/runtests/issue5901.clif
Normal file
21
cranelift/filetests/filetests/runtests/issue5901.clif
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
test interpret
|
||||||
|
test run
|
||||||
|
target aarch64
|
||||||
|
target s390x
|
||||||
|
target x86_64
|
||||||
|
target riscv64
|
||||||
|
|
||||||
|
function %a(i8) -> i8 sext system_v {
|
||||||
|
ss2 = explicit_slot 2
|
||||||
|
|
||||||
|
block0(v0: i8):
|
||||||
|
v2 = iconst.i16 0x00ff
|
||||||
|
v3 = stack_addr.i64 ss2
|
||||||
|
store little v2, v3
|
||||||
|
|
||||||
|
v4 = stack_addr.i64 ss2+1
|
||||||
|
v5 = atomic_cas little v4, v0, v0
|
||||||
|
return v5
|
||||||
|
}
|
||||||
|
|
||||||
|
; run: %a(0) == 0
|
||||||
Reference in New Issue
Block a user