Add x86 SIMD legalization of icmp ne

This commit is contained in:
Andrew Brown
2019-10-23 15:40:46 -07:00
parent f8c3dfeb17
commit e3a20d67b2
3 changed files with 67 additions and 0 deletions

View File

@@ -496,6 +496,16 @@ pub(crate) fn define(shared: &mut SharedDefinitions, x86_instructions: &Instruct
}
}
// SIMD icmp ne
let ne = Literal::enumerator_for(&imm.intcc, "ne");
for ty in ValueType::all_lane_types().filter(|ty| allowed_simd_type(ty) && ty.is_int()) {
let icmp_ = icmp.bind(vector(ty, sse_vector_size));
narrow.legalize(
def!(c = icmp_(ne, a, b)),
vec![def!(x = icmp(eq, a, b)), def!(c = bnot(x))],
);
}
narrow.custom_legalize(shuffle, "convert_shuffle");
narrow.custom_legalize(extractlane, "convert_extractlane");
narrow.custom_legalize(insertlane, "convert_insertlane");

View File

@@ -0,0 +1,12 @@
test legalizer
set enable_simd
target x86_64 skylake
function %icmp_ne_32x4(i32x4, i32x4) -> b32x4 {
ebb0(v0: i32x4, v1: i32x4):
v2 = icmp ne v0, v1
; check: v3 = icmp eq v0, v1
; nextln: v4 = vconst.b32x4 0xffffffffffffffffffffffffffffffff
; nextln: v2 = bxor v4, v3
return v2
}

View File

@@ -0,0 +1,45 @@
test run
set enable_simd
target x86_64 skylake
function %icmp_eq_i8x16() -> b8 {
ebb0:
v0 = vconst.i8x16 0x00
v1 = vconst.i8x16 0x00
v2 = icmp eq v0, v1
v3 = extractlane v2, 0
return v3
}
; run
function %icmp_eq_i64x2() -> b64 {
ebb0:
v0 = vconst.i64x2 0xffffffffffffffffffffffffffffffff
v1 = vconst.i64x2 0xffffffffffffffffffffffffffffffff
v2 = icmp eq v0, v1
v3 = extractlane v2, 1
return v3
}
; run
function %icmp_ne_i32x4() -> b1 {
ebb0:
v0 = vconst.i32x4 [0 1 2 3]
v1 = vconst.i32x4 [7 7 7 7]
v2 = icmp ne v0, v1
v3 = vall_true v2
return v3
}
; run
function %icmp_ne_i16x8() -> b1 {
ebb0:
v0 = vconst.i16x8 [0 1 2 3 4 5 6 7]
v1 = vconst.i16x8 [0 1 2 3 4 5 6 7]
v2 = icmp ne v0, v1
v3 = vall_true v2
v4 = bint.i32 v3
v5 = icmp_imm eq v4, 0
return v5
}
; run