intel/fs: Fix D to W conversion in opt_combine_constants
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 19 Apr 2019 18:32:59 +0000 (11:32 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 24 Apr 2019 02:48:33 +0000 (19:48 -0700)
commit21223acf7d5b39e5eb2b248330519cdbee3e63e8
tree6c0c82eb4b0a45ba8b1f30b575a39826650edfbc
parente4ec814c392c5405a363f64e14864623d5c1b10c
intel/fs: Fix D to W conversion in opt_combine_constants

Found by GCC warning:

src/intel/compiler/brw_fs_combine_constants.cpp: In function ‘bool needs_negate(const fs_reg*, const imm*)’:
src/intel/compiler/brw_fs_combine_constants.cpp:306:34: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
       return ((reg->d & 0xffffu) < 0) != (imm->w < 0);
               ~~~~~~~~~~~~~~~~~~~^~~

The result of the bit-and is a 32-bit value with the top bits all zero.
This will never be < 0.  Instead of masking off the bits, just cast to
int16_t and let the compiler handle the actual conversion.

Fixes: e64be391dd0 ("intel/compiler: generalize the combine constants pass")
Cc: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/compiler/brw_fs_combine_constants.cpp