From ac602c97c98b720fab5fb50ffa7349b2d9b41e39 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Tue, 19 Aug 2025 21:35:07 -0700 Subject: [PATCH] brw: Fix folding case for MAD instruction with all immediates Fixes: b605f76b2a6 ("brw/algebraic: Constant fold multiplicands of MAD") Reviewed-by: Lionel Landwerlin Part-of: (cherry picked from commit 74a4e7dd4b53e2b4407af089e46ef86aa12cb60a) --- .pick_status.json | 2 +- src/intel/compiler/brw_opt_algebraic.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index d67f7fb292d..0d73d4685e4 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -6814,7 +6814,7 @@ "description": "brw: Fix folding case for MAD instruction with all immediates", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "b605f76b2a6b19194a3f4f29d7bb40e47648cda3", "notes": null diff --git a/src/intel/compiler/brw_opt_algebraic.cpp b/src/intel/compiler/brw_opt_algebraic.cpp index 00d50ce3c3d..1e532daaeb4 100644 --- a/src/intel/compiler/brw_opt_algebraic.cpp +++ b/src/intel/compiler/brw_opt_algebraic.cpp @@ -181,12 +181,12 @@ brw_opt_constant_fold_instruction(const intel_device_info *devinfo, brw_inst *in break; case BRW_OPCODE_MAD: - if (inst->src[1].file == IMM && + if (inst->src[0].file == IMM && + inst->src[1].file == IMM && inst->src[2].file == IMM && - inst->src[3].file == IMM && + !brw_type_is_vector_imm(inst->src[0].type) && !brw_type_is_vector_imm(inst->src[1].type) && - !brw_type_is_vector_imm(inst->src[2].type) && - !brw_type_is_vector_imm(inst->src[3].type)) { + !brw_type_is_vector_imm(inst->src[2].type)) { fold_multiplicands_of_MAD(inst); assert(inst->opcode == BRW_OPCODE_ADD);