From 74a4e7dd4b53e2b4407af089e46ef86aa12cb60a 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: --- src/intel/compiler/brw_opt_algebraic.cpp | 8 ++++---- src/intel/compiler/test_opt_algebraic.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/intel/compiler/brw_opt_algebraic.cpp b/src/intel/compiler/brw_opt_algebraic.cpp index 2e26c12c1bf..3d1931daef8 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); diff --git a/src/intel/compiler/test_opt_algebraic.cpp b/src/intel/compiler/test_opt_algebraic.cpp index e3e8acd2af0..397b6aefd90 100644 --- a/src/intel/compiler/test_opt_algebraic.cpp +++ b/src/intel/compiler/test_opt_algebraic.cpp @@ -59,7 +59,7 @@ TEST_F(algebraic_test, fmax_a_a) EXPECT_NO_PROGRESS(brw_opt_algebraic, bld); } -TEST_F(algebraic_test, mad_with_all_immediates_DISABLED) +TEST_F(algebraic_test, mad_with_all_immediates) { brw_builder bld = make_shader(); brw_builder exp = make_shader();