aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <[email protected]>2019-12-16 13:37:41 -0800
committerCaio Marcelo de Oliveira Filho <[email protected]>2019-12-17 10:45:22 -0800
commit2137be22fa2c75eda462456f2b7778684d0631fc (patch)
treeaa8a77384b4c84e307a1b82059bd369985b107e1 /src
parent66013cb1be2bd60d88d78ebe1624a5556a0460f7 (diff)
intel/fs: Fix lowering of dword multiplication by 16-bit constant
Existing code was ignoring whether the type of the immediate source was signed or not. If the source was signed, it would ignore small negative values but it also would wrongly accept values between INT16_MAX and UINT16_MAX, causing the atual value to later be reinterpreted as a negative number (under 16-bits). Fixes tests/shaders/glsl-mul-const.shader_test in Piglit for platforms that don't support MUL with 32x32 types, including ICL and TGL. Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2186 Cc: <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/intel/compiler/brw_fs.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index a01b01048c8..beeac84e43d 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -3908,7 +3908,10 @@ fs_visitor::lower_mul_dword_inst(fs_inst *inst, bblock_t *block)
{
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.
@@ -3921,7 +3924,6 @@ fs_visitor::lower_mul_dword_inst(fs_inst *inst, bblock_t *block)
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));