From 8477678cfeb3ab0d80983ec5901742baf786d8cf Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 14 Oct 2020 21:23:00 -0400 Subject: [PATCH] pan/bi: Fix handling of small constants in bi_lookup_constant Streamline the logic and the bug goes away. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_pack.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index dfff5ec9403..9f0884bf60a 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -74,24 +74,14 @@ bi_pack_header(bi_clause *clause, bi_clause *next_1, bi_clause *next_2, bool tdd 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; }