pan/bi: Fix handling of small constants in bi_lookup_constant
Streamline the logic and the bug goes away.
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7206>
diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c
index dfff5ec..9f0884b 100644
--- a/src/panfrost/bifrost/bi_pack.c
+++ b/src/panfrost/bifrost/bi_pack.c
@@ -74,24 +74,14 @@
static unsigned
bi_lookup_constant(bi_clause *clause, uint32_t cons, bool *hi)
{
- uint64_t want = (cons >> 4);
-
for (unsigned i = 0; i < clause->constant_count; ++i) {
- /* Only check top 60-bits since that's what's actually embedded
- * in the clause, the bottom 4-bits are bundle-inline */
+ /* Try to apply to top or to bottom */
+ uint64_t top = clause->constants[i];
- uint64_t candidates[2] = {
- clause->constants[i] >> 4,
- clause->constants[i] >> 36
- };
-
- /* Treat lo/hi separately */
- candidates[0] &= (0xFFFFFFFF >> 4);
-
- if (candidates[0] == want)
+ if (cons == ((uint32_t) top | (cons & 0xF)))
return i;
- if (candidates[1] == want) {
+ if (cons == (top >> 32ul)) {
*hi = true;
return i;
}