Add x86 SIMD vall_true

In order to implement SIMD's all_true (https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#all-lanes-true), we must legalize some instruction (I chose `vall_true`) to a comparison against 0 and a similar reduction as vany_true using `PTEST` and `SETNZ`. Since `icmp` only allows integers but `vall_true` could allow more vector types, `raw_bitcast` is used to convert the lane types into integers, e.g. b32x4 to i32x4. To do so without runtime type-checking, the `raw_bitcast` instruction (which emits no instruction) can now bitcast from any vector type to the same type, e.g. i32x4 to i32x4.
This commit is contained in:
Andrew Brown
2019-10-18 16:21:06 -07:00
parent 65e18df12f
commit 879ccf871a
4 changed files with 78 additions and 0 deletions

View File

@@ -17,3 +17,13 @@ ebb0(v0: b32x4):
; nextln: v1 = trueif ne v2
return v1
}
function %vall_true_i64x2(i64x2) -> b1 {
ebb0(v0: i64x2):
v1 = vall_true v0
; check: v2 = vconst.i64x2 0x00
; nextln: v3 = icmp eq v0, v2
; nextln: v4 = x86_ptest v3, v3
; nextln: v1 = trueif eq v4
return v1
}

View File

@@ -39,3 +39,21 @@ ebb0:
return v3
}
; run
function %vall_true_i16x8() -> b1 {
ebb0:
v0 = vconst.i16x8 [1 0 0 0 0 0 0 0]
v1 = vall_true v0
v2 = bint.i32 v1
v3 = icmp_imm eq v2, 0
return v3
}
; run
function %vall_true_b32x4() -> b1 {
ebb0:
v0 = vconst.b32x4 [true true true true]
v1 = vall_true v0
return v1
}
; run