aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2011-08-18 12:42:22 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2011-08-18 12:42:22 +0000
commit6b8045e1bb221bff9ca107b3bd9109b9de044bc1 (patch)
tree67722dd90363343ba8f112a4246a54e507e3688c /gcc/tree.c
parent68f932c4432b9b806d58781aa56ad7b3ba5e82f9 (diff)
downloadgcc-6b8045e1bb221bff9ca107b3bd9109b9de044bc1.zip
gcc-6b8045e1bb221bff9ca107b3bd9109b9de044bc1.tar.gz
gcc-6b8045e1bb221bff9ca107b3bd9109b9de044bc1.tar.bz2
tree.h (tree_int_cst_msb): Remove.
2011-08-18 Richard Guenther <rguenther@suse.de> * tree.h (tree_int_cst_msb): Remove. * tree.c (tree_int_cst_msb): Likewise. (tree_int_cst_sign_bit): Move from ... * tree-ssa-loop-ivopts.c (tree_int_cst_sign_bit): ... here. From-SVN: r177853
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 3eaf2f9..714ccbb 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -6513,21 +6513,23 @@ tree_low_cst (const_tree t, int pos)
return TREE_INT_CST_LOW (t);
}
-/* Return the most significant bit of the integer constant T. */
+/* Return the most significant (sign) bit of T. */
int
-tree_int_cst_msb (const_tree t)
+tree_int_cst_sign_bit (const_tree t)
{
- int prec;
- HOST_WIDE_INT h;
- unsigned HOST_WIDE_INT l;
-
- /* Note that using TYPE_PRECISION here is wrong. We care about the
- actual bits, not the (arbitrary) range of the type. */
- prec = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (t))) - 1;
- rshift_double (TREE_INT_CST_LOW (t), TREE_INT_CST_HIGH (t), prec,
- 2 * HOST_BITS_PER_WIDE_INT, &l, &h, 0);
- return (l & 1) == 1;
+ unsigned bitno = TYPE_PRECISION (TREE_TYPE (t)) - 1;
+ unsigned HOST_WIDE_INT w;
+
+ if (bitno < HOST_BITS_PER_WIDE_INT)
+ w = TREE_INT_CST_LOW (t);
+ else
+ {
+ w = TREE_INT_CST_HIGH (t);
+ bitno -= HOST_BITS_PER_WIDE_INT;
+ }
+
+ return (w >> bitno) & 1;
}
/* Return an indication of the sign of the integer constant T.