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]

Fix wi::lshift


Hello,

because of an other bug, __builtin_constant_p is ignored in some cases, and this bug in wide_int went unnoticed. I am fixing it by making it match more closely the comment above.

Bootstrap+regtest together with a fix for __builtin_constant_p on x86_64-pc-linux-gnu.

2019-07-11  Marc Glisse  <marc.glisse@inria.fr>

	* wide-int.h (wi::lshift): Reject negative values for the fast path.

--
Marc Glisse
Index: gcc/wide-int.h
===================================================================
--- gcc/wide-int.h	(revision 273306)
+++ gcc/wide-int.h	(working copy)
@@ -3025,22 +3025,22 @@ wi::lshift (const T1 &x, const T2 &y)
 	 handle the case where the shift value is constant and the
 	 result is a single nonnegative HWI (meaning that we don't
 	 need to worry about val[1]).  This is particularly common
 	 for converting a byte count to a bit count.
 
 	 For variable-precision integers like wide_int, handle HWI
 	 and sub-HWI integers inline.  */
       if (STATIC_CONSTANT_P (xi.precision > HOST_BITS_PER_WIDE_INT)
 	  ? (STATIC_CONSTANT_P (shift < HOST_BITS_PER_WIDE_INT - 1)
 	     && xi.len == 1
-	     && xi.val[0] <= (HOST_WIDE_INT) ((unsigned HOST_WIDE_INT)
-					      HOST_WIDE_INT_MAX >> shift))
+	     && xi.val[0] >= 0
+	     && xi.val[0] <= HOST_WIDE_INT_MAX >> shift)
 	  : precision <= HOST_BITS_PER_WIDE_INT)
 	{
 	  val[0] = xi.ulow () << shift;
 	  result.set_len (1);
 	}
       else
 	result.set_len (lshift_large (val, xi.val, xi.len,
 				      precision, shift));
     }
   return result;

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