mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-06 00:10:20 +01:00
intel/mi_builder: Add ieq/ine helpers
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9445>
This commit is contained in:
parent
2c02740a8c
commit
62b9e30cc7
2 changed files with 34 additions and 4 deletions
|
|
@ -789,6 +789,28 @@ mi_isub(struct mi_builder *b, struct mi_value src0, struct mi_value src1)
|
|||
MI_ALU_STORE, MI_ALU_ACCU);
|
||||
}
|
||||
|
||||
static inline struct mi_value
|
||||
mi_ieq(struct mi_builder *b, struct mi_value src0, struct mi_value src1)
|
||||
{
|
||||
if (src0.type == MI_VALUE_TYPE_IMM && src1.type == MI_VALUE_TYPE_IMM)
|
||||
return mi_imm(mi_value_to_u64(src0) == mi_value_to_u64(src1) ? ~0ull : 0);
|
||||
|
||||
/* Compute "equal" by subtracting and storing the zero bit */
|
||||
return mi_math_binop(b, MI_ALU_SUB, src0, src1,
|
||||
MI_ALU_STORE, MI_ALU_ZF);
|
||||
}
|
||||
|
||||
static inline struct mi_value
|
||||
mi_ine(struct mi_builder *b, struct mi_value src0, struct mi_value src1)
|
||||
{
|
||||
if (src0.type == MI_VALUE_TYPE_IMM && src1.type == MI_VALUE_TYPE_IMM)
|
||||
return mi_imm(mi_value_to_u64(src0) != mi_value_to_u64(src1) ? ~0ull : 0);
|
||||
|
||||
/* Compute "not equal" by subtracting and storing the inverse zero bit */
|
||||
return mi_math_binop(b, MI_ALU_SUB, src0, src1,
|
||||
MI_ALU_STOREINV, MI_ALU_ZF);
|
||||
}
|
||||
|
||||
static inline struct mi_value
|
||||
mi_ult(struct mi_builder *b, struct mi_value src0, struct mi_value src1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -537,7 +537,7 @@ TEST_F(mi_builder_test, add_imm)
|
|||
EXPECT_EQ(*(uint64_t *)(output + 104), value + add);
|
||||
}
|
||||
|
||||
TEST_F(mi_builder_test, ilt_uge)
|
||||
TEST_F(mi_builder_test, ult_uge_ieq_ine)
|
||||
{
|
||||
uint64_t values[8] = {
|
||||
0x0123456789abcdef,
|
||||
|
|
@ -553,10 +553,14 @@ TEST_F(mi_builder_test, ilt_uge)
|
|||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(values); i++) {
|
||||
for (unsigned j = 0; j < ARRAY_SIZE(values); j++) {
|
||||
mi_store(&b, out_mem64(i * 128 + j * 16 + 0),
|
||||
mi_store(&b, out_mem64(i * 256 + j * 32 + 0),
|
||||
mi_ult(&b, in_mem64(i * 8), in_mem64(j * 8)));
|
||||
mi_store(&b, out_mem64(i * 128 + j * 16 + 8),
|
||||
mi_store(&b, out_mem64(i * 256 + j * 32 + 8),
|
||||
mi_uge(&b, in_mem64(i * 8), in_mem64(j * 8)));
|
||||
mi_store(&b, out_mem64(i * 256 + j * 32 + 16),
|
||||
mi_ieq(&b, in_mem64(i * 8), in_mem64(j * 8)));
|
||||
mi_store(&b, out_mem64(i * 256 + j * 32 + 24),
|
||||
mi_ine(&b, in_mem64(i * 8), in_mem64(j * 8)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -564,11 +568,15 @@ TEST_F(mi_builder_test, ilt_uge)
|
|||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(values); i++) {
|
||||
for (unsigned j = 0; j < ARRAY_SIZE(values); j++) {
|
||||
uint64_t *out_u64 = (uint64_t *)(output + i * 128 + j * 16);
|
||||
uint64_t *out_u64 = (uint64_t *)(output + i * 256 + j * 32);
|
||||
EXPECT_EQ_IMM(out_u64[0], mi_ult(&b, mi_imm(values[i]),
|
||||
mi_imm(values[j])));
|
||||
EXPECT_EQ_IMM(out_u64[1], mi_uge(&b, mi_imm(values[i]),
|
||||
mi_imm(values[j])));
|
||||
EXPECT_EQ_IMM(out_u64[2], mi_ieq(&b, mi_imm(values[i]),
|
||||
mi_imm(values[j])));
|
||||
EXPECT_EQ_IMM(out_u64[3], mi_ine(&b, mi_imm(values[i]),
|
||||
mi_imm(values[j])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue