def test_vselect_vsplits_vconcats(self): # type: () -> None r = Rtl( self.v3 << vselect(self.v0, self.v1, self.v2), (self.v4, self.v5) << vsplit(self.v3), (self.v6, self.v7) << vsplit(self.v4), self.v8 << vconcat(self.v3, self.v3), self.v9 << vconcat(self.v8, self.v8), ) ti = TypeEnv() typing = ti_rtl(r, ti) t = TypeVar("t", "", ints=True, bools=True, floats=True, simd=(4, 64)) check_typing(typing, ({ self.v0: t.as_bool(), self.v1: t, self.v2: t, self.v3: t, self.v4: t.half_vector(), self.v5: t.half_vector(), self.v6: t.half_vector().half_vector(), self.v7: t.half_vector().half_vector(), self.v8: t.double_vector(), self.v9: t.double_vector().double_vector(), }, []))
def test_vselect_icmpimm(self): # type: () -> None x = Var('x') y = Var('y') z = Var('z') w = Var('w') v = Var('v') zeroes = Var('zeroes') imm0 = Var("imm0") r = Rtl( zeroes << iconst(imm0), y << icmp(intcc.eq, x, zeroes), v << vselect(y, z, w), ) r1 = r.copy({}) s = r.substitution(r1, {}) s[zeroes].set_typevar(TypeVar.singleton(i32.by(4))) s[z].set_typevar(TypeVar.singleton(f32.by(4))) r1.cleanup_concrete_rtl() assert s is not None assert s[zeroes].get_typevar().singleton_type() == i32.by(4) assert s[x].get_typevar().singleton_type() == i32.by(4) assert s[y].get_typevar().singleton_type() == b32.by(4) assert s[z].get_typevar().singleton_type() == f32.by(4) assert s[w].get_typevar().singleton_type() == f32.by(4) assert s[v].get_typevar().singleton_type() == f32.by(4)
def test_enumeration_with_constraints(self): # type: () -> None xform = XForm( Rtl( self.v0 << iconst(self.imm0), self.v1 << icmp(intcc.eq, self.v2, self.v0), self.v5 << vselect(self.v1, self.v3, self.v4) ), Rtl( self.v0 << iconst(self.imm0), self.v1 << icmp(intcc.eq, self.v2, self.v0), self.v5 << vselect(self.v1, self.v3, self.v4) )) # Check all var assigns are correct assert len(xform.ti.constraints) > 0 concrete_var_assigns = list(xform.ti.concrete_typings()) v0 = xform.symtab[str(self.v0)] v1 = xform.symtab[str(self.v1)] v2 = xform.symtab[str(self.v2)] v3 = xform.symtab[str(self.v3)] v4 = xform.symtab[str(self.v4)] v5 = xform.symtab[str(self.v5)] for var_m in concrete_var_assigns: assert var_m[v0] == var_m[v2] and \ var_m[v3] == var_m[v4] and\ var_m[v5] == var_m[v3] and\ var_m[v1] == var_m[v2].as_bool() and\ var_m[v1].get_typeset() == var_m[v3].as_bool().get_typeset() check_concrete_typing_xform(var_m, xform) # The number of possible typings here is: # 8 cases for v0 = i8xN times 2 options for v3 - i8, b8 = 16 # 8 cases for v0 = i16xN times 2 options for v3 - i16, b16 = 16 # 8 cases for v0 = i32xN times 3 options for v3 - i32, b32, f32 = 24 # 8 cases for v0 = i64xN times 3 options for v3 - i64, b64, f64 = 24 # # (Note we have 8 cases for lanes since vselect prevents scalars) # Total: 2*16 + 2*24 = 80 assert len(concrete_var_assigns) == 80
def test_vselect(self): # type: () -> None r = Rtl(self.v0 << vselect(self.v1, self.v2, self.v3), ) ti = TypeEnv() typing = ti_rtl(r, ti) txn = self.TxN.get_fresh_copy("TxN1") check_typing(typing, ({ self.v0: txn, self.v1: txn.as_bool(), self.v2: txn, self.v3: txn }, []))
def test_vselect(self): # type: () -> None r = Rtl( self.v0 << vselect(self.v1, self.v2, self.v3), ) ti = TypeEnv() typing = ti_rtl(r, ti) txn = self.TxN.get_fresh_copy("TxN1") check_typing(typing, ({ self.v0: txn, self.v1: txn.as_bool(), self.v2: txn, self.v3: txn }, []))
def test_vselect_imm(self): # type: () -> None ts = TypeSet(lanes=(2, 256), ints=True, floats=True, bools=(8, 64)) r = Rtl( self.v0 << iconst(self.imm0), self.v1 << icmp(intcc.eq, self.v2, self.v0), self.v5 << vselect(self.v1, self.v3, self.v4), ) x = XForm(r, r) tv2_exp = 'Some({}).map(|t: Type| -> t.as_bool())'\ .format(self.v2.get_typevar().name) tv3_exp = 'Some({}).map(|t: Type| -> t.as_bool())'\ .format(self.v3.get_typevar().name) self.check_yo_check( x, sequence(typeset_check(self.v3, ts), equiv_check(tv2_exp, tv3_exp)))
def test_vselect_imm(self): # type: () -> None ts = TypeSet(lanes=(2, 256), ints=True, floats=True, bools=(8, 64)) r = Rtl( self.v0 << iconst(self.imm0), self.v1 << icmp(intcc.eq, self.v2, self.v0), self.v5 << vselect(self.v1, self.v3, self.v4), ) x = XForm(r, r) tv2_exp = 'Some({}).map(|t: crate::ir::Type| t.as_bool())'\ .format(self.v2.get_typevar().name) tv3_exp = 'Some({}).map(|t: crate::ir::Type| t.as_bool())'\ .format(self.v3.get_typevar().name) self.check_yo_check( x, sequence(typeset_check(self.v3, ts), equiv_check(tv2_exp, tv3_exp)))
def test_vselect_icmpimm(self): # type: () -> None r = Rtl( self.v0 << iconst(self.imm0), self.v1 << icmp(intcc.eq, self.v2, self.v0), self.v5 << vselect(self.v1, self.v3, self.v4), ) ti = TypeEnv() typing = ti_rtl(r, ti) ixn = self.IxN_nonscalar.get_fresh_copy("IxN1") txn = self.TxN.get_fresh_copy("TxN1") check_typing(typing, ({ self.v0: ixn, self.v1: ixn.as_bool(), self.v2: ixn, self.v3: txn, self.v4: txn, self.v5: txn, }, [TypesEqual(ixn.as_bool(), txn.as_bool())]))