From: Jason Ekstrand Date: Wed, 3 Apr 2019 19:59:20 +0000 (-0500) Subject: intel/common: Support bigger right-shifts with mi_builder X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=316a98dec99ff1cfb848b0220141a47d52bcd24c;p=mesa.git intel/common: Support bigger right-shifts with mi_builder Because why not? --- 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)