[ewasm] Change eq() in polyfill to branch-less version

This commit is contained in:
Alex Beregszaszi
2020-11-27 22:47:55 +00:00
parent 887569efd5
commit 06af2fb38a
3 changed files with 71 additions and 55 deletions
+3 -3
View File
@@ -90,9 +90,9 @@ function mul_64x64_128(x, y) -> hi, lo {
// value split into four 64 bit values.
function mul_128x128_256(x1, x2, y1, y2) -> r1, r2, r3, r4 {
let ah, al := mul_64x64_128(x1, y1)
let bh, bl := mul_64x64_128(x1, y2)
let ch, cl := mul_64x64_128(x2, y1)
let dh, dl := mul_64x64_128(x2, y2)
let bh, bl := mul_64x64_128(x1, y2)
let ch, cl := mul_64x64_128(x2, y1)
let dh, dl := mul_64x64_128(x2, y2)
r4 := dl
let carry1, carry2
let t1, t2
+12 -9
View File
@@ -35,15 +35,18 @@ function iszero512(x1, x2, x3, x4, x5, x6, x7, x8) -> r:i32 {
}
function eq(x1, x2, x3, x4, y1, y2, y3, y4) -> r1, r2, r3, r4 {
if i64.eq(x1, y1) {
if i64.eq(x2, y2) {
if i64.eq(x3, y3) {
if i64.eq(x4, y4) {
r4 := 1
}
}
}
}
r4 := i64.extend_i32_u(
i32.and(
i64.eq(x1, y1),
i32.and(
i64.eq(x2, y2),
i32.and(
i64.eq(x3, y3),
i64.eq(x4, y4)
)
)
)
)
}
// returns 0 if a == b, -1 if a < b and 1 if a > b