jay: follow source order for mad/bfe

otherwise s == 0 checks don't do the right thing.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42056>
This commit is contained in:
Alyssa Rosenzweig 2026-06-05 16:40:29 -04:00 committed by Marge Bot
parent 7e74ba122a
commit 8085f983b1
4 changed files with 6 additions and 9 deletions

View file

@ -326,11 +326,12 @@ pass(jay_function *func)
* it works fine on Lunar Lake so ¯\_()_/¯ ... gate on !strict.
*/
if ((I->op == JAY_OPCODE_MAD && I->type == JAY_TYPE_F32) &&
(I->src[2].file == ACCUM && I->src[2].reg == 0) &&
!(I->src[2].negate || I->src[2].abs) &&
(I->src[0].file == ACCUM && I->src[0].reg == 0) &&
!(I->src[0].negate || I->src[0].abs) &&
!(jay_debug & JAY_DBG_STRICT)) {
I->op = JAY_OPCODE_MAC;
SWAP(I->src[0], I->src[2]);
}
/* Sometimes this algorithm turns nontrivial GPR->GPR copies into

View file

@ -514,14 +514,14 @@ jay_emit_alu(struct nir_to_jay_state *nj, nir_alu_instr *alu)
case nir_op_ubfe:
case nir_op_ibfe:
jay_BFE(b, type, dst, src[0], src[1], src[2]);
jay_BFE(b, type, dst, src[2], src[1], src[0]);
break;
case nir_op_bfi:
jay_BFI2(b, dst, src[0], src[1], src[2]);
break;
case nir_op_ffma:
jay_MAD(b, type, dst, src[0], src[1], src[2]);
jay_MAD(b, type, dst, src[2], src[1], src[0]);
break;
case nir_op_fcsel:

View file

@ -98,7 +98,7 @@ op('fbl', 1, 'u32')
op('lzd', 1, 'u32')
op('frc', 1, 'f32 f64', Props.NEGATE | Props.CMOD)
op('mad', 3, 'u32 s32 u16 s16 f32 f64 f16 bf16',
Props.NEGATE | Props.SAT | Props.CMOD | Props.COMMUTATIVE)
Props.NEGATE | Props.SAT | Props.CMOD)
op('mac', 3, 'f32', Props.NEGATE | Props.SAT | Props.CMOD |
Props.COMMUTATIVE)
op('max', 2, 'u32 s32 u64 s64 u16 s16 f32 f64 f16 bf16',

View file

@ -367,10 +367,6 @@ emit(struct jay_codegen *jc,
gen->src[i] = to_gen_operand(f, I, i, simd_offs, false);
}
if (I->op == JAY_OPCODE_MAD || I->op == JAY_OPCODE_BFE) {
SWAP(gen->src[0], gen->src[2]);
}
switch (I->op) {
case JAY_OPCODE_WHILE: {
assert(util_dynarray_num_elements(&jc->loop_stack, int) > 0);