intel/fs: Fix handling of W, UW, and HF constants in combine_constants

Sources that are already W, UW, or HF can be represented as those types
by definition. Pass them through. Previously an HF source on a MAD would
have been marked as !can_promote. I'm pretty sure this means it would
get moved out to a register, but I did not verify this.

For ADD3, a constant source could be D or UD. In this case, the value
must be tested to determine whether it can be represented as W or
UW. The patterns in opt_algebraic won't generate an ADD3 with constant
source, so this problem cannot occur yet.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23262>
This commit is contained in:
Ian Romanick 2023-05-23 18:34:43 -07:00 committed by Marge Bot
parent 4cc3206218
commit 4f272bf001

View file

@ -376,7 +376,7 @@ can_promote_src_as_imm(const struct intel_device_info *devinfo, fs_inst *inst,
}
break;
}
case BRW_REGISTER_TYPE_W: {
case BRW_REGISTER_TYPE_D: {
int16_t w;
if (representable_as_w(inst->src[src_idx].d, &w)) {
inst->src[src_idx] = brw_imm_w(w);
@ -384,7 +384,7 @@ can_promote_src_as_imm(const struct intel_device_info *devinfo, fs_inst *inst,
}
break;
}
case BRW_REGISTER_TYPE_UW: {
case BRW_REGISTER_TYPE_UD: {
uint16_t uw;
if (representable_as_uw(inst->src[src_idx].ud, &uw)) {
inst->src[src_idx] = brw_imm_uw(uw);
@ -392,6 +392,11 @@ can_promote_src_as_imm(const struct intel_device_info *devinfo, fs_inst *inst,
}
break;
}
case BRW_REGISTER_TYPE_W:
case BRW_REGISTER_TYPE_UW:
case BRW_REGISTER_TYPE_HF:
can_promote = true;
break;
default:
break;
}