This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Quash Wbool-compare warning in optabs.c


On Tue, Aug 19, 2014 at 07:52:33AM -0700, Richard Henderson wrote:
> On 08/19/2014 07:12 AM, Marek Polacek wrote:
> > On some archs, C[TL]Z_DEFINED_VALUE_AT_ZERO macros return only
> > true/false, so -Wbool-compare would warn.
> 
> Then we should fix them to return 0/1 instead.

Works as well.  So is the following ok once the regtest finishes?

Bootstrapped on x86_64-linux.

2014-08-19  Marek Polacek  <polacek@redhat.com>

	* config/alpha/alpha.h (CLZ_DEFINED_VALUE_AT_ZERO,
	CTZ_DEFINED_VALUE_AT_ZERO): Return 0/1 rather than bool.
	* config/i386/i386.h (CLZ_DEFINED_VALUE_AT_ZERO,
	CTZ_DEFINED_VALUE_AT_ZERO): Return 0/1 rather than bool.

diff --git gcc/config/alpha/alpha.h gcc/config/alpha/alpha.h
index 0ff793f..88816f3 100644
--- gcc/config/alpha/alpha.h
+++ gcc/config/alpha/alpha.h
@@ -912,8 +912,10 @@ do {									     \
 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
 
 /* The CIX ctlz and cttz instructions return 64 for zero.  */
-#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  ((VALUE) = 64, TARGET_CIX)
-#define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  ((VALUE) = 64, TARGET_CIX)
+#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  ((VALUE) = 64, \
+  TARGET_CIX ? 1 : 0)
+#define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  ((VALUE) = 64, \
+  TARGET_CIX ? 1 : 0)
 
 /* Define the value returned by a floating-point comparison instruction.  */
 
diff --git gcc/config/i386/i386.h gcc/config/i386/i386.h
index ec6ed25..2c64162 100644
--- gcc/config/i386/i386.h
+++ gcc/config/i386/i386.h
@@ -2498,9 +2498,9 @@ extern void debug_dispatch_window (int);
 /* The value at zero is only defined for the BMI instructions
    LZCNT and TZCNT, not the BSR/BSF insns in the original isa.  */
 #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
-	((VALUE) = GET_MODE_BITSIZE (MODE), TARGET_BMI)
+	((VALUE) = GET_MODE_BITSIZE (MODE), TARGET_BMI ? 1 : 0)
 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
-	((VALUE) = GET_MODE_BITSIZE (MODE), TARGET_LZCNT)
+	((VALUE) = GET_MODE_BITSIZE (MODE), TARGET_LZCNT ? 1 : 0)
 
 
 /* Flags returned by ix86_get_callcvt ().  */

	Marek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]