cranelift: Fix icmp_imm for small types in interpreter (#4506)
This commit is contained in:
77
cranelift/filetests/filetests/runtests/icmp-eq-imm.clif
Normal file
77
cranelift/filetests/filetests/runtests/icmp-eq-imm.clif
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
test interpret
|
||||||
|
test run
|
||||||
|
target aarch64
|
||||||
|
target x86_64
|
||||||
|
target s390x
|
||||||
|
|
||||||
|
function %icmp_imm_eq_i8(i8) -> b1 {
|
||||||
|
block0(v0: i8):
|
||||||
|
v1 = icmp_imm eq v0, 0x44
|
||||||
|
return v1
|
||||||
|
}
|
||||||
|
; run: %icmp_imm_eq_i8(0) == false
|
||||||
|
; run: %icmp_imm_eq_i8(-1) == false
|
||||||
|
; run: %icmp_imm_eq_i8(0x44) == true
|
||||||
|
|
||||||
|
function %icmp_neg_eq_i8(i8) -> b1 {
|
||||||
|
block0(v0: i8):
|
||||||
|
v1 = icmp_imm eq v0, 0xf4
|
||||||
|
return v1
|
||||||
|
}
|
||||||
|
; run: %icmp_neg_eq_i8(0) == false
|
||||||
|
; run: %icmp_neg_eq_i8(-1) == false
|
||||||
|
; run: %icmp_neg_eq_i8(0xf4) == true
|
||||||
|
|
||||||
|
function %icmp_imm_eq_i16(i16) -> b1 {
|
||||||
|
block0(v0: i16):
|
||||||
|
v1 = icmp_imm eq v0, 0x4444
|
||||||
|
return v1
|
||||||
|
}
|
||||||
|
; run: %icmp_imm_eq_i16(0) == false
|
||||||
|
; run: %icmp_imm_eq_i16(-1) == false
|
||||||
|
; run: %icmp_imm_eq_i16(0x4444) == true
|
||||||
|
|
||||||
|
function %icmp_neg_eq_i16(i16) -> b1 {
|
||||||
|
block0(v0: i16):
|
||||||
|
v1 = icmp_imm eq v0, 0xff44
|
||||||
|
return v1
|
||||||
|
}
|
||||||
|
; run: %icmp_neg_eq_i16(0) == false
|
||||||
|
; run: %icmp_neg_eq_i16(-1) == false
|
||||||
|
; run: %icmp_neg_eq_i16(0xff44) == true
|
||||||
|
|
||||||
|
function %icmp_imm_eq_i32(i32) -> b1 {
|
||||||
|
block0(v0: i32):
|
||||||
|
v1 = icmp_imm eq v0, 0x4444_4444
|
||||||
|
return v1
|
||||||
|
}
|
||||||
|
; run: %icmp_imm_eq_i32(0) == false
|
||||||
|
; run: %icmp_imm_eq_i32(-1) == false
|
||||||
|
; run: %icmp_imm_eq_i32(0x4444_4444) == true
|
||||||
|
|
||||||
|
function %icmp_neg_eq_i32(i32) -> b1 {
|
||||||
|
block0(v0: i32):
|
||||||
|
v1 = icmp_imm eq v0, 0xffff_4444
|
||||||
|
return v1
|
||||||
|
}
|
||||||
|
; run: %icmp_neg_eq_i32(0) == false
|
||||||
|
; run: %icmp_neg_eq_i32(-1) == false
|
||||||
|
; run: %icmp_neg_eq_i32(0xffff_4444) == true
|
||||||
|
|
||||||
|
function %icmp_imm_eq_i64(i64) -> b1 {
|
||||||
|
block0(v0: i64):
|
||||||
|
v1 = icmp_imm eq v0, 0x4444_4444_4444_4444
|
||||||
|
return v1
|
||||||
|
}
|
||||||
|
; run: %icmp_imm_eq_i64(0) == false
|
||||||
|
; run: %icmp_imm_eq_i64(-1) == false
|
||||||
|
; run: %icmp_imm_eq_i64(0x4444_4444_4444_4444) == true
|
||||||
|
|
||||||
|
function %icmp_neg_eq_i64(i64) -> b1 {
|
||||||
|
block0(v0: i64):
|
||||||
|
v1 = icmp_imm eq v0, 0xffff_ffff_4444_4444
|
||||||
|
return v1
|
||||||
|
}
|
||||||
|
; run: %icmp_neg_eq_i64(0) == false
|
||||||
|
; run: %icmp_neg_eq_i64(-1) == false
|
||||||
|
; run: %icmp_neg_eq_i64(0xffff_ffff_4444_4444) == true
|
||||||
@@ -2,6 +2,7 @@ test interpret
|
|||||||
test run
|
test run
|
||||||
target aarch64
|
target aarch64
|
||||||
target x86_64
|
target x86_64
|
||||||
|
target s390x
|
||||||
|
|
||||||
function %icmp_eq_i8(i8, i8) -> b1 {
|
function %icmp_eq_i8(i8, i8) -> b1 {
|
||||||
block0(v0: i8, v1: i8):
|
block0(v0: i8, v1: i8):
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ test interpret
|
|||||||
test run
|
test run
|
||||||
target aarch64
|
target aarch64
|
||||||
target x86_64
|
target x86_64
|
||||||
|
target s390x
|
||||||
|
|
||||||
function %icmp_ne_i8(i8, i8) -> b1 {
|
function %icmp_ne_i8(i8, i8) -> b1 {
|
||||||
block0(v0: i8, v1: i8):
|
block0(v0: i8, v1: i8):
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ test interpret
|
|||||||
test run
|
test run
|
||||||
target aarch64
|
target aarch64
|
||||||
target x86_64
|
target x86_64
|
||||||
|
target s390x
|
||||||
|
|
||||||
|
|
||||||
function %icmp_sge_i8(i8, i8) -> b1 {
|
function %icmp_sge_i8(i8, i8) -> b1 {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ test interpret
|
|||||||
test run
|
test run
|
||||||
target aarch64
|
target aarch64
|
||||||
target x86_64
|
target x86_64
|
||||||
|
target s390x
|
||||||
|
|
||||||
|
|
||||||
function %icmp_sgt_i8(i8, i8) -> b1 {
|
function %icmp_sgt_i8(i8, i8) -> b1 {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ test interpret
|
|||||||
test run
|
test run
|
||||||
target aarch64
|
target aarch64
|
||||||
target x86_64
|
target x86_64
|
||||||
|
target s390x
|
||||||
|
|
||||||
|
|
||||||
function %icmp_sle_i8(i8, i8) -> b1 {
|
function %icmp_sle_i8(i8, i8) -> b1 {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ test interpret
|
|||||||
test run
|
test run
|
||||||
target aarch64
|
target aarch64
|
||||||
target x86_64
|
target x86_64
|
||||||
|
target s390x
|
||||||
|
|
||||||
function %icmp_slt_i8(i8, i8) -> b1 {
|
function %icmp_slt_i8(i8, i8) -> b1 {
|
||||||
block0(v0: i8, v1: i8):
|
block0(v0: i8, v1: i8):
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ test interpret
|
|||||||
test run
|
test run
|
||||||
target aarch64
|
target aarch64
|
||||||
target x86_64
|
target x86_64
|
||||||
|
target s390x
|
||||||
|
|
||||||
function %icmp_uge_i8(i8, i8) -> b1 {
|
function %icmp_uge_i8(i8, i8) -> b1 {
|
||||||
block0(v0: i8, v1: i8):
|
block0(v0: i8, v1: i8):
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ test interpret
|
|||||||
test run
|
test run
|
||||||
target aarch64
|
target aarch64
|
||||||
target x86_64
|
target x86_64
|
||||||
|
target s390x
|
||||||
|
|
||||||
function %icmp_ule_i8(i8, i8) -> b1 {
|
function %icmp_ule_i8(i8, i8) -> b1 {
|
||||||
block0(v0: i8, v1: i8):
|
block0(v0: i8, v1: i8):
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ test interpret
|
|||||||
test run
|
test run
|
||||||
target aarch64
|
target aarch64
|
||||||
target x86_64
|
target x86_64
|
||||||
|
target s390x
|
||||||
|
|
||||||
function %icmp_ult_i8(i8, i8) -> b1 {
|
function %icmp_ult_i8(i8, i8) -> b1 {
|
||||||
block0(v0: i8, v1: i8):
|
block0(v0: i8, v1: i8):
|
||||||
|
|||||||
@@ -294,9 +294,7 @@ impl Value for DataValue {
|
|||||||
Ok(match kind {
|
Ok(match kind {
|
||||||
ValueConversionKind::Exact(ty) => match (self, ty) {
|
ValueConversionKind::Exact(ty) => match (self, ty) {
|
||||||
// TODO a lot to do here: from bmask to ireduce to raw_bitcast...
|
// TODO a lot to do here: from bmask to ireduce to raw_bitcast...
|
||||||
(DataValue::I64(n), types::I32) => DataValue::I32(i32::try_from(n)?),
|
(DataValue::I64(n), ty) if ty.is_int() => DataValue::from_integer(n as i128, ty)?,
|
||||||
(DataValue::I64(n), types::I64) => DataValue::I64(n),
|
|
||||||
(DataValue::I64(n), types::I128) => DataValue::I128(n as i128),
|
|
||||||
(DataValue::F32(n), types::I32) => DataValue::I32(n.bits() as i32),
|
(DataValue::F32(n), types::I32) => DataValue::I32(n.bits() as i32),
|
||||||
(DataValue::F64(n), types::I64) => DataValue::I64(n.bits() as i64),
|
(DataValue::F64(n), types::I64) => DataValue::I64(n.bits() as i64),
|
||||||
(DataValue::B(b), t) if t.is_bool() => DataValue::B(b),
|
(DataValue::B(b), t) if t.is_bool() => DataValue::B(b),
|
||||||
|
|||||||
Reference in New Issue
Block a user