diff options
author | Jason Ekstrand <[email protected]> | 2019-04-03 14:59:20 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-04-11 18:04:09 +0000 |
commit | 316a98dec99ff1cfb848b0220141a47d52bcd24c (patch) | |
tree | 7837ed204f27090602a5ef8525fd154ac6f5e2bc /src/intel/common | |
parent | 0d6dea0ac87ec3ca089c4ab637fd07a2f488e6a1 (diff) |
intel/common: Support bigger right-shifts with mi_builder
Because why not?
Diffstat (limited to 'src/intel/common')
-rw-r--r-- | src/intel/common/gen_mi_builder.h | 12 | ||||
-rw-r--r-- | src/intel/common/tests/gen_mi_builder_test.cpp | 11 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/intel/common/gen_mi_builder.h b/src/intel/common/gen_mi_builder.h index 22c0aee3343..a67126930d6 100644 --- a/src/intel/common/gen_mi_builder.h +++ b/src/intel/common/gen_mi_builder.h @@ -689,6 +689,18 @@ gen_mi_ushr32_imm(struct gen_mi_builder *b, /* We right-shift by left-shifting by 32 - shift and taking the top 32 bits * of the result. This assumes the top 32 bits are zero. */ + if (shift > 64) + return gen_mi_imm(0); + + if (shift > 32) { + struct gen_mi_value tmp = gen_mi_new_gpr(b); + _gen_mi_copy_no_unref(b, gen_mi_value_half(tmp, false), + gen_mi_value_half(src, true)); + _gen_mi_copy_no_unref(b, gen_mi_value_half(tmp, true), gen_mi_imm(0)); + gen_mi_value_unref(b, src); + src = tmp; + shift -= 32; + } assert(shift <= 32); struct gen_mi_value tmp = gen_mi_ishl_imm(b, src, 32 - shift); struct gen_mi_value dst = gen_mi_new_gpr(b); diff --git a/src/intel/common/tests/gen_mi_builder_test.cpp b/src/intel/common/tests/gen_mi_builder_test.cpp index d192e063d00..b1e210ba450 100644 --- a/src/intel/common/tests/gen_mi_builder_test.cpp +++ b/src/intel/common/tests/gen_mi_builder_test.cpp @@ -625,15 +625,20 @@ TEST_F(gen_mi_builder_test, ushr32_imm) const uint64_t value = 0x0123456789abcdef; memcpy(input, &value, sizeof(value)); - const unsigned max_shift = 31; + const unsigned max_shift = 64; for (unsigned i = 0; i <= max_shift; i++) gen_mi_store(&b, out_mem64(i * 8), gen_mi_ushr32_imm(&b, in_mem64(0), i)); submit_batch(); - for (unsigned i = 0; i <= max_shift; i++) - EXPECT_EQ(*(uint64_t *)(output + i * 8), (value >> i) & UINT32_MAX); + for (unsigned i = 0; i <= max_shift; i++) { + if (i >= 64) { + EXPECT_EQ(*(uint64_t *)(output + i * 8), 0); + } else { + EXPECT_EQ(*(uint64_t *)(output + i * 8), (value >> i) & UINT32_MAX); + } + } } TEST_F(gen_mi_builder_test, udiv32_imm) |