From c1c09e3c4a0fedd777442828efefb672e99b8dbc Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 25 Oct 2024 20:03:41 -0700 Subject: [PATCH] brw/emit: Add correct 3-source instruction assertions for each platform Specifically, allow two immediate sources for BFE on Gfx12+. I stumbled on this while trying some stuff with !31852. v2: Don't be lazy. Add proper assertions for all the things on all the platforms. Based on a suggestion by Ken. Reviewed-by: Kenneth Graunke Fixes: 7bed11fbdeb ("intel/brw: Allow immediates in the BFE instruction on Gfx12+") Part-of: --- src/intel/compiler/brw_eu_emit.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/intel/compiler/brw_eu_emit.c b/src/intel/compiler/brw_eu_emit.c index 12758b71534..c22fd1435b4 100644 --- a/src/intel/compiler/brw_eu_emit.c +++ b/src/intel/compiler/brw_eu_emit.c @@ -548,9 +548,27 @@ brw_alu3(struct brw_codegen *p, unsigned opcode, struct brw_reg dest, assert(dest.nr < XE2_MAX_GRF); - if (devinfo->ver >= 10) - assert(!(src0.file == IMM && - src2.file == IMM)); + if (devinfo->ver <= 9) { + assert(src0.file != IMM && src2.file != IMM); + } else if (devinfo->ver <= 11) { + /* On Ice Lake, BFE and CSEL cannot have any immediate sources. */ + assert((opcode != BRW_OPCODE_BFE && opcode != BRW_OPCODE_CSEL) || + (src0.file != IMM && src2.file != IMM)); + + /* On Ice Lake, DP4A and MAD can only have one immediate source. */ + assert((opcode != BRW_OPCODE_DP4A && opcode != BRW_OPCODE_MAD) || + !(src0.file == IMM && src2.file == IMM)); + } else { + /* Having two immediate sources is allowed, but this should have been + * converted to a regular ADD by brw_fs_opt_algebraic. + */ + assert(opcode == BRW_OPCODE_ADD3 || + !(src0.file == IMM && src2.file == IMM)); + } + + /* BFI2 cannot have any immediate sources on any platform. */ + assert(opcode != BRW_OPCODE_BFI2 || + (src0.file != IMM && src2.file != IMM)); assert(src0.file == IMM || src0.nr < XE2_MAX_GRF); assert(src1.file != IMM && src1.nr < XE2_MAX_GRF);