Mesa (android-radeonsi-build-fix): intel/compiler: Fix 'comparison is always true' warning

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Dec 5 08:08:27 UTC 2019


Module: Mesa
Branch: android-radeonsi-build-fix
Commit: 668635abd26dda458f9293f99dd39f56431a4d61
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=668635abd26dda458f9293f99dd39f56431a4d61

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Mon Nov 18 19:16:23 2019 -0800

intel/compiler: Fix 'comparison is always true' warning

Without looking at the assembly or something, I'm not sure what the
compiler does here.  The brw_reg_type enum is marked packed, so I'm
guess that it gets represented as a uint8_t.  That's the only reason I
could think that comparing with -1 would be always true.

This patch adds the same cast that exists in brw_hw_type_to_reg_type.
It might be better to add a #define outside the enum for
BRW_REGISTER_TYPE_INVALID as (enum brw_reg_type)-1.

src/intel/compiler/brw_eu_compact.c: In function ‘has_immediate’:
src/intel/compiler/brw_eu_compact.c:1515:20: warning: comparison is always true due to limited range of data type [-Wtype-limits]
 1515 |       return *type != -1;
      |                    ^~
src/intel/compiler/brw_eu_compact.c:1518:20: warning: comparison is always true due to limited range of data type [-Wtype-limits]
 1518 |       return *type != -1;
      |                    ^~

Reviewed-by: Eric Engestrom <eric.engestrom at intel.com>
CID: 1455194
Fixes: 12d3b11908e ("intel/compiler: Add instruction compaction support on Gen12")
Cc: @mattst88

---

 src/intel/compiler/brw_eu_compact.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/intel/compiler/brw_eu_compact.c b/src/intel/compiler/brw_eu_compact.c
index 9155da04c77..4d2e617b3ed 100644
--- a/src/intel/compiler/brw_eu_compact.c
+++ b/src/intel/compiler/brw_eu_compact.c
@@ -1512,10 +1512,10 @@ has_immediate(const struct gen_device_info *devinfo, const brw_inst *inst,
 {
    if (brw_inst_src0_reg_file(devinfo, inst) == BRW_IMMEDIATE_VALUE) {
       *type = brw_inst_src0_type(devinfo, inst);
-      return *type != -1;
+      return *type != (enum brw_reg_type)-1;
    } else if (brw_inst_src1_reg_file(devinfo, inst) == BRW_IMMEDIATE_VALUE) {
       *type = brw_inst_src1_type(devinfo, inst);
-      return *type != -1;
+      return *type != (enum brw_reg_type)-1;
    }
 
    return false;




More information about the mesa-commit mailing list