From 972d517d41f72c68661b7478bd9a54963cc85da8 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 26 Jul 2021 11:14:33 -0400 Subject: [PATCH] pan/bi: Use bi_apply_swizzle in constant folding Much more legible now. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_opt_constant_fold.c | 26 ++++----------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/panfrost/bifrost/bi_opt_constant_fold.c b/src/panfrost/bifrost/bi_opt_constant_fold.c index 91550843a3a..e1c048fc0ed 100644 --- a/src/panfrost/bifrost/bi_opt_constant_fold.c +++ b/src/panfrost/bifrost/bi_opt_constant_fold.c @@ -31,33 +31,15 @@ static uint32_t bi_fold_constant(bi_instr *I, bool *unsupported) { - uint32_t a = I->src[0].value; - uint32_t b = I->src[1].value; + uint32_t a = bi_apply_swizzle(I->src[0].value, I->src[0].swizzle); + uint32_t b = bi_apply_swizzle(I->src[1].value, I->src[1].swizzle); switch (I->op) { case BI_OPCODE_SWZ_V2I16: - { - uint16_t lo = (a & 0xFFFF); - uint16_t hi = (a >> 16); - - enum bi_swizzle swz = I->src[0].swizzle; - assert(swz < BI_SWIZZLE_H11); - - /* Note order is H00, H01, H10, H11 */ - return (((swz & (1 << 1)) ? hi : lo) << 0) | - (((swz & (1 << 0)) ? hi : lo) << 16); - } + return a; case BI_OPCODE_MKVEC_V2I16: - { - bool hi_a = I->src[0].swizzle & BI_SWIZZLE_H11; - bool hi_b = I->src[1].swizzle & BI_SWIZZLE_H11; - - uint16_t lo = (hi_a ? (a >> 16) : (a & 0xFFFF)); - uint16_t hi = (hi_b ? (b >> 16) : (b & 0xFFFF)); - - return (hi << 16) | lo; - } + return (b << 16) | (a & 0xFFFF); default: *unsupported = true;