From 8f53de4a5d1fb4de992d2a4b6d1fa4bf042d8603 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+") (cherry picked from commit c1c09e3c4a0fedd777442828efefb672e99b8dbc) Part-of: --- .pick_status.json | 2 +- src/intel/compiler/brw_eu_emit.c | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index aa35c780bd3..ec8efad1cc6 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -14,7 +14,7 @@ "description": "brw/emit: Add correct 3-source instruction assertions for each platform", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "7bed11fbdebbd70cf12d1ff55d15db7231b7e9ad", "notes": null 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);