From 83010c57a62ce83521da8ebd2f1f716dd86243ce Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 11 Mar 2022 16:09:28 -0600 Subject: [PATCH] bifrost: Simplify derivatives a bit Instead of two magic ternary operations, define a new `axis` temporary which is 1 for X and 2 for Y. Then define everything else in terms of this variable. In particular, the mask operation we do on LANE_ID is a mask so it makes more sense to use ~axis than 1/2 but in the other order. Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 5ea945f7231..b811e1f5a69 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -2141,13 +2141,14 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr) case nir_op_fddx: case nir_op_fddy: { + unsigned axis = instr->op == nir_op_fddx ? 1 : 2; bi_index lane1 = bi_lshift_and_i32(b, bi_fau(BIR_FAU_LANE_ID, false), - bi_imm_u32(instr->op == nir_op_fddx ? 2 : 1), + bi_imm_u32(0x3 & ~axis), bi_imm_u8(0)); bi_index lane2 = bi_iadd_u32(b, lane1, - bi_imm_u32(instr->op == nir_op_fddx ? 1 : 2), + bi_imm_u32(axis), false); bi_index left, right;