diff mbox

[wide-int] Fix LTO regression that I'd introduced

Message ID 87bo3o63p8.fsf@talisman.default
State New
Headers show

Commit Message

Richard Sandiford Sept. 19, 2013, 6:56 p.m. UTC
It turns out that gcc20's version of binutils is too old for the LTO plugin,
so the tests I'd been running hadn't exercised it.  This patch fixes a
regression that Kenny pointed out.

The problem was that build_int_cst and build_int_cst_type were using
the signedness of the type to decide how the HWI should be extended,
whereas they're supposed to use sign extension regardless.

Tested on x86_64-linux-gnu, this time with trunk binutils.  OK for wide-int?

Thanks,
Richard


gcc/
	* tree.h (wi::hwi): Delete.
	* tree.c (build_int_cst, build_int_cst_type): Use wi::shwi.
	(build_int_cstu): Use wi::uhwi.

Comments

Kenneth Zadeck Sept. 19, 2013, 7:12 p.m. UTC | #1
this looks fine to me.
On 09/19/2013 02:56 PM, Richard Sandiford wrote:
> It turns out that gcc20's version of binutils is too old for the LTO plugin,
> so the tests I'd been running hadn't exercised it.  This patch fixes a
> regression that Kenny pointed out.
>
> The problem was that build_int_cst and build_int_cst_type were using
> the signedness of the type to decide how the HWI should be extended,
> whereas they're supposed to use sign extension regardless.
>
> Tested on x86_64-linux-gnu, this time with trunk binutils.  OK for wide-int?
>
> Thanks,
> Richard
>
>
> gcc/
> 	* tree.h (wi::hwi): Delete.
> 	* tree.c (build_int_cst, build_int_cst_type): Use wi::shwi.
> 	(build_int_cstu): Use wi::uhwi.
>
> Index: gcc/tree.h
> ===================================================================
> --- gcc/tree.h	(revision 202746)
> +++ gcc/tree.h	(working copy)
> @@ -5206,8 +5206,6 @@
>   
>   namespace wi
>   {
> -  hwi_with_prec hwi (HOST_WIDE_INT, const_tree);
> -
>     template <typename T>
>     bool fits_to_tree_p (const T &x, const_tree);
>   
> @@ -5216,12 +5214,6 @@
>     wide_int from_mpz (const_tree, mpz_t, bool);
>   }
>   
> -inline wi::hwi_with_prec
> -wi::hwi (HOST_WIDE_INT val, const_tree type)
> -{
> -  return hwi_with_prec (val, TYPE_PRECISION (type), TYPE_SIGN (type));
> -}
> -
>   template <typename T>
>   bool
>   wi::fits_to_tree_p (const T &x, const_tree type)
> Index: gcc/tree.c
> ===================================================================
> --- gcc/tree.c	(revision 202746)
> +++ gcc/tree.c	(working copy)
> @@ -1056,13 +1056,13 @@
>     if (!type)
>       type = integer_type_node;
>   
> -  return wide_int_to_tree (type, wi::hwi (low, type));
> +  return wide_int_to_tree (type, wi::shwi (low, TYPE_PRECISION (type)));
>   }
>   
>   tree
>   build_int_cstu (tree type, unsigned HOST_WIDE_INT cst)
>   {
> -  return wide_int_to_tree (type, wi::hwi (cst, type));
> +  return wide_int_to_tree (type, wi::uhwi (cst, TYPE_PRECISION (type)));
>   }
>   
>   /* Create an INT_CST node with a LOW value sign extended to TYPE.  */
> @@ -1071,7 +1071,7 @@
>   build_int_cst_type (tree type, HOST_WIDE_INT low)
>   {
>     gcc_assert (type);
> -  return wide_int_to_tree (type, wi::hwi (low, type));
> +  return wide_int_to_tree (type, wi::shwi (low, TYPE_PRECISION (type)));
>   }
>   
>   /* Constructs tree in type TYPE from with value given by CST.  Signedness
diff mbox

Patch

Index: gcc/tree.h
===================================================================
--- gcc/tree.h	(revision 202746)
+++ gcc/tree.h	(working copy)
@@ -5206,8 +5206,6 @@ 
 
 namespace wi
 {
-  hwi_with_prec hwi (HOST_WIDE_INT, const_tree);
-
   template <typename T>
   bool fits_to_tree_p (const T &x, const_tree);
 
@@ -5216,12 +5214,6 @@ 
   wide_int from_mpz (const_tree, mpz_t, bool);
 }
 
-inline wi::hwi_with_prec
-wi::hwi (HOST_WIDE_INT val, const_tree type)
-{
-  return hwi_with_prec (val, TYPE_PRECISION (type), TYPE_SIGN (type));
-}
-
 template <typename T>
 bool
 wi::fits_to_tree_p (const T &x, const_tree type)
Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 202746)
+++ gcc/tree.c	(working copy)
@@ -1056,13 +1056,13 @@ 
   if (!type)
     type = integer_type_node;
 
-  return wide_int_to_tree (type, wi::hwi (low, type));
+  return wide_int_to_tree (type, wi::shwi (low, TYPE_PRECISION (type)));
 }
 
 tree
 build_int_cstu (tree type, unsigned HOST_WIDE_INT cst)
 {
-  return wide_int_to_tree (type, wi::hwi (cst, type));
+  return wide_int_to_tree (type, wi::uhwi (cst, TYPE_PRECISION (type)));
 }
 
 /* Create an INT_CST node with a LOW value sign extended to TYPE.  */
@@ -1071,7 +1071,7 @@ 
 build_int_cst_type (tree type, HOST_WIDE_INT low)
 {
   gcc_assert (type);
-  return wide_int_to_tree (type, wi::hwi (low, type));
+  return wide_int_to_tree (type, wi::shwi (low, TYPE_PRECISION (type)));
 }
 
 /* Constructs tree in type TYPE from with value given by CST.  Signedness