Mesa (master): intel/fs: Fix D to W conversion in opt_combine_constants
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Apr 24 03:04:07 UTC 2019
Module: Mesa
Branch: master
Commit: 21223acf7d5b39e5eb2b248330519cdbee3e63e8
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=21223acf7d5b39e5eb2b248330519cdbee3e63e8
Author: Ian Romanick <ian.d.romanick at intel.com>
Date: Fri Apr 19 11:32:59 2019 -0700
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 at igalia.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
---
src/intel/compiler/brw_fs_combine_constants.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/intel/compiler/brw_fs_combine_constants.cpp b/src/intel/compiler/brw_fs_combine_constants.cpp
index db7b14a8312..8d16be4c4bb 100644
--- a/src/intel/compiler/brw_fs_combine_constants.cpp
+++ b/src/intel/compiler/brw_fs_combine_constants.cpp
@@ -303,7 +303,7 @@ needs_negate(const struct fs_reg *reg, const struct imm *imm)
case BRW_REGISTER_TYPE_HF:
return (reg->d & 0x8000u) != (imm->w & 0x8000u);
case BRW_REGISTER_TYPE_W:
- return ((reg->d & 0xffffu) < 0) != (imm->w < 0);
+ return ((int16_t)reg->d < 0) != (imm->w < 0);
case BRW_REGISTER_TYPE_UQ:
case BRW_REGISTER_TYPE_UD:
case BRW_REGISTER_TYPE_UW:
More information about the mesa-commit
mailing list