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