From a84e3a0f55d85fefb90450868e4cd01dce63e503 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 26 Nov 2024 15:12:32 -0800 Subject: [PATCH] brw/const: Allow mixing signed and unsigned immediate sources No shader-db or fossil-db changes on any Intel platform. This commit just prevents issues with a later commit, "brw/copy: Don't try to be clever about ADD3 constant propagation." v2: Use 'can_promote = true; break;' instead of 'return true;'. Suggested by Caio. Reviewed-by: Caio Oliveira Reviewed-by: Matt Turner Part-of: --- .../compiler/brw_fs_combine_constants.cpp | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/intel/compiler/brw_fs_combine_constants.cpp b/src/intel/compiler/brw_fs_combine_constants.cpp index d0b2f352053..8e8becc9417 100644 --- a/src/intel/compiler/brw_fs_combine_constants.cpp +++ b/src/intel/compiler/brw_fs_combine_constants.cpp @@ -1049,19 +1049,29 @@ can_promote_src_as_imm(const struct intel_device_info *devinfo, fs_inst *inst, } break; } - case BRW_TYPE_D: { - int16_t w; - if (representable_as_w(inst->src[src_idx].d, &w)) { - inst->src[src_idx] = brw_imm_w(w); - can_promote = true; - } - break; - } + case BRW_TYPE_D: case BRW_TYPE_UD: { - uint16_t uw; - if (representable_as_uw(inst->src[src_idx].ud, &uw)) { - inst->src[src_idx] = brw_imm_uw(uw); - can_promote = true; + /* ADD3, CSEL, and MAD can mix signed and unsiged types. Only BFE + * cannot. + */ + if (inst->src[src_idx].type == BRW_TYPE_D || + inst->opcode != BRW_OPCODE_BFE) { + int16_t w; + if (representable_as_w(inst->src[src_idx].d, &w)) { + inst->src[src_idx] = brw_imm_w(w); + can_promote = true; + break; + } + } + + if (inst->src[src_idx].type == BRW_TYPE_UD || + inst->opcode != BRW_OPCODE_BFE) { + uint16_t uw; + if (representable_as_uw(inst->src[src_idx].ud, &uw)) { + inst->src[src_idx] = brw_imm_uw(uw); + can_promote = true; + break; + } } break; }