{
const fs_builder ibld(this, block, inst);
- if (inst->src[1].file == IMM && inst->src[1].ud < (1 << 16)) {
+ const bool ud = (inst->src[1].type == BRW_REGISTER_TYPE_UD);
+ if (inst->src[1].file == IMM &&
+ (( ud && inst->src[1].ud <= UINT16_MAX) ||
+ (!ud && inst->src[1].d <= INT16_MAX && inst->src[1].d >= INT16_MIN))) {
/* The MUL instruction isn't commutative. On Gen <= 6, only the low
* 16-bits of src0 are read, and on Gen >= 7 only the low 16-bits of
* src1 are used.
ibld.MOV(imm, inst->src[1]);
ibld.MUL(inst->dst, imm, inst->src[0]);
} else {
- const bool ud = (inst->src[1].type == BRW_REGISTER_TYPE_UD);
ibld.MUL(inst->dst, inst->src[0],
ud ? brw_imm_uw(inst->src[1].ud)
: brw_imm_w(inst->src[1].d));