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 <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15352>
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;