Add x86 SIMD vany_true and x86_ptest

In order to implement SIMD's any_true (https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#any-lane-true), we must legalize some instruction (I chose `vany_true`) to a sequence of `PTEST` and `SETNZ`. To emit `PTEST` I added the new CLIF instruction `x86_ptest` and used CLIF's `trueif ne` for `SETNZ`.
This commit is contained in:
Andrew Brown
2019-10-18 15:35:27 -07:00
parent 873465e7a9
commit 186effc420
8 changed files with 89 additions and 0 deletions

View File

@@ -25,3 +25,9 @@ ebb0(v0: b64x2 [%xmm6], v1: b64x2 [%xmm3]):
[-, %xmm3] v2 = band_not v0, v1 ; bin: 66 0f df de
return v2
}
function %x86_ptest_f64x2(f64x2, f64x2) {
ebb0(v0: f64x2 [%xmm0], v1: f64x2 [%xmm2]):
[-, %rflags] v2 = x86_ptest v0, v1 ; bin: 66 0f 38 17 c2
return
}

View File

@@ -9,3 +9,11 @@ ebb0(v0: b32x4):
; nextln: v1 = bxor v2, v0
return v1
}
function %vany_true_b32x4(b32x4) -> b1 {
ebb0(v0: b32x4):
v1 = vany_true v0
; check: v2 = x86_ptest v0, v0
; nextln: v1 = trueif ne v2
return v1
}

View File

@@ -21,3 +21,21 @@ ebb0:
return v4
}
; run
function %vany_true_i16x8() -> b1 {
ebb0:
v0 = vconst.i16x8 [1 0 0 0 0 0 0 0]
v1 = vany_true v0
return v1
}
; run
function %vany_true_b32x4() -> b1 {
ebb0:
v0 = vconst.b32x4 [false false false false]
v1 = vany_true v0
v2 = bint.i32 v1
v3 = icmp_imm eq v2, 0
return v3
}
; run