intel/compiler: Fix 'comparison is always true' warning
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 19 Nov 2019 03:16:23 +0000 (19:16 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 4 Dec 2019 23:34:03 +0000 (15:34 -0800)
commit668635abd26dda458f9293f99dd39f56431a4d61
treefa60ea49f53980ace38a7a1c1bf4914d4386ac09
parent5b3d6979a61c2159d85aba2ca0960540c6b80b2d
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@intel.com>
CID: 1455194
Fixes: 12d3b11908e ("intel/compiler: Add instruction compaction support on Gen12")
Cc: @mattst88
src/intel/compiler/brw_eu_compact.c