cranelift: Fix urem/srem in interpreter (#4532)
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
test run
|
||||
set avoid_div_traps=false
|
||||
target aarch64
|
||||
target s390x
|
||||
set avoid_div_traps=false
|
||||
target x86_64
|
||||
|
||||
; Tests that the `avoid_div_traps` flag prevents a trap when {s,u}rem is called
|
||||
; with INT_MIN % -1.
|
||||
|
||||
function %i8(i8, i8) -> i8 {
|
||||
block0(v0: i8, v1: i8):
|
||||
v2 = srem.i8 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i8(0, 1) == 0
|
||||
; run: %i8(1, -1) == 0
|
||||
; run: %i8(0x80, 0xff) == 0
|
||||
; run: %i8(0x2, 0x7) == 0x2
|
||||
|
||||
function %i8_const(i8) -> i8 {
|
||||
block0(v0: i8):
|
||||
@@ -20,19 +20,13 @@ block0(v0: i8):
|
||||
v2 = srem.i8 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i8_const(0) == 0
|
||||
; run: %i8_const(1) == 0
|
||||
; run: %i8_const(0x80) == 0
|
||||
; run: %i8_const(0x2) == 0
|
||||
|
||||
function %i16(i16, i16) -> i16 {
|
||||
block0(v0: i16, v1: i16):
|
||||
v2 = srem.i16 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i16(0, 42) == 0
|
||||
; run: %i16(4, -2) == 0
|
||||
; run: %i16(13, 5) == 3
|
||||
; run: %i16(0x8000, 0xffff) == 0
|
||||
|
||||
function %i16_const(i16) -> i16 {
|
||||
@@ -41,9 +35,6 @@ block0(v0: i16):
|
||||
v2 = srem.i16 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i16_const(0) == 0
|
||||
; run: %i16_const(4) == 0
|
||||
; run: %i16_const(13) == 0
|
||||
; run: %i16_const(0x8000) == 0
|
||||
|
||||
function %i32(i32, i32) -> i32 {
|
||||
@@ -51,9 +42,6 @@ block0(v0: i32, v1: i32):
|
||||
v2 = srem.i32 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i32(0, 13) == 0
|
||||
; run: %i32(1048576, 8192) == 0
|
||||
; run: %i32(-1024, 255) == -4
|
||||
; run: %i32(0x80000000, 0xffffffff) == 0
|
||||
|
||||
function %i32_const(i32) -> i32 {
|
||||
@@ -62,9 +50,6 @@ block0(v0: i32):
|
||||
v2 = srem.i32 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i32_const(0) == 0
|
||||
; run: %i32_const(1057) == 0
|
||||
; run: %i32_const(-42) == 0
|
||||
; run: %i32_const(0x80000000) == 0
|
||||
|
||||
function %i64(i64, i64) -> i64 {
|
||||
@@ -72,9 +57,6 @@ block0(v0: i64, v1: i64):
|
||||
v2 = srem.i64 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i64(0, 104857600000) == 0
|
||||
; run: %i64(104857600000, 511) == 398
|
||||
; run: %i64(-57, -5) == -2
|
||||
; run: %i64(0x800000000000000, 0xffffffffffffffff) == 0
|
||||
|
||||
function %i64_const(i64) -> i64 {
|
||||
@@ -83,9 +65,6 @@ block0(v0: i64):
|
||||
v2 = srem.i64 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i64_const(0) == 0
|
||||
; run: %i64_const(104857600000) == 0
|
||||
; run: %i64_const(-57) == 0
|
||||
; run: %i64_const(0x800000000000000) == 0
|
||||
|
||||
function %i8_u(i8, i8) -> i8 {
|
||||
@@ -93,10 +72,6 @@ block0(v0: i8,v1: i8):
|
||||
v2 = urem v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i8_u(0, 1) == 0
|
||||
; run: %i8_u(2, 2) == 0
|
||||
; run: %i8_u(1, -1) == 1
|
||||
; run: %i8_u(3, 2) == 1
|
||||
; run: %i8_u(0x80, 0xff) == 0x80
|
||||
|
||||
function %i8_u_const(i8) -> i8 {
|
||||
@@ -105,8 +80,6 @@ block0(v0: i8):
|
||||
v2 = urem v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i8_u_const(0) == 0
|
||||
; run: %i8_u_const(3) == 3
|
||||
; run: %i8_u_const(0x80) == 0x80
|
||||
|
||||
function %i16_u(i16, i16) -> i16 {
|
||||
@@ -114,9 +87,6 @@ block0(v0: i16, v1: i16):
|
||||
v2 = urem.i16 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i16_u(0, 42) == 0
|
||||
; run: %i16_u(4, -2) == 4
|
||||
; run: %i16_u(13, 5) == 3
|
||||
; run: %i16_u(0x8000, 0xffff) == 0x8000
|
||||
|
||||
function %i16_u_const(i16) -> i16 {
|
||||
@@ -125,8 +95,6 @@ block0(v0: i16):
|
||||
v2 = urem.i16 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i16_u_const(0) == 0
|
||||
; run: %i16_u_const(4) == 4
|
||||
; run: %i16_u_const(0x8000) == 0x8000
|
||||
|
||||
function %i32_u(i32, i32) -> i32 {
|
||||
@@ -134,9 +102,6 @@ block0(v0: i32, v1: i32):
|
||||
v2 = urem.i32 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i32_u(0, 13) == 0
|
||||
; run: %i32_u(1048576, 8192) == 0
|
||||
; run: %i32_u(-1024, 255) == 252
|
||||
; run: %i32_u(0x80000000, 0xffffffff) == 0x80000000
|
||||
|
||||
function %i32_u_const(i32) -> i32 {
|
||||
@@ -145,9 +110,6 @@ block0(v0: i32):
|
||||
v2 = urem.i32 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i32_u_const(0) == 0
|
||||
; run: %i32_u_const(1057) == 1057
|
||||
; run: %i32_u_const(-42) == -42
|
||||
; run: %i32_u_const(0x80000000) == 0x80000000
|
||||
|
||||
function %i64_u(i64, i64) -> i64 {
|
||||
@@ -155,9 +117,6 @@ block0(v0: i64, v1: i64):
|
||||
v2 = urem.i64 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i64_u(0, 104857600000) == 0
|
||||
; run: %i64_u(104857600000, 511) == 398
|
||||
; run: %i64_u(-57, -5) == -57
|
||||
; run: %i64_u(0x800000000000000, 0xffffffffffffffff) == 0x800000000000000
|
||||
|
||||
function %i64_u_const(i64) -> i64 {
|
||||
@@ -166,7 +125,4 @@ block0(v0: i64):
|
||||
v2 = urem.i64 v0, v1
|
||||
return v2
|
||||
}
|
||||
; run: %i64_u_const(0) == 0
|
||||
; run: %i64_u_const(104857600000) == 104857600000
|
||||
; run: %i64_u_const(-57) == -57
|
||||
; run: %i64_u_const(0x800000000000000) == 0x800000000000000
|
||||
|
||||
Reference in New Issue
Block a user