From 4cc3206218aa9b16939842a67d4a988d8e416d6d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 1 Jun 2023 14:21:13 -0700 Subject: [PATCH] intel/fs: Don't munge source order of 3-src instructions in opt_algebraic This only impacts ADD3, so at this point it should not have any affect. As soon as constants are propagated into ADD3 instructions, it will be a problem. The worst part is, the ADD3 instrutions that are broken by the old code aren't even "progress" on this pass. Reviewed-by: Matt Turner Part-of: --- src/intel/compiler/brw_fs.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 7681f32b8ea..119045ab633 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -2828,8 +2828,13 @@ fs_visitor::opt_algebraic() break; } - /* Swap if src[0] is immediate. */ - if (progress && inst->is_commutative()) { + /* Ensure that the correct source has the immediate value. 2-source + * instructions must have the immediate in src[1]. On Gfx12 and later, + * some 3-source instructions can have the immediate in src[0] or + * src[2]. It's complicated, so don't mess with 3-source instructions + * here. + */ + if (progress && inst->sources == 2 && inst->is_commutative()) { if (inst->src[0].file == IMM) { fs_reg tmp = inst->src[1]; inst->src[1] = inst->src[0];