Patchwork Remove unused tree_int_cst_msb

login
register
mail settings
Submitter Richard Guenther
Date Aug. 18, 2011, 11:24 a.m.
Message ID <alpine.LNX.2.00.1108181320200.2130@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/110510/
State New
Headers show

Comments

Richard Guenther - Aug. 18, 2011, 11:24 a.m.
This removes the fortunately unused tree_int_cst_msb with its
strange semantics

  /* Note that using TYPE_PRECISION here is wrong.  We care about the
     actual bits, not the (arbitrary) range of the type.  */

and "replaces" it by the existing tree_int_cst_sign_bit which has
the expected semantics.

Pending a bootstrap & regtest I'll commit this shortly.

Richard.

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.

Patch

Index: trunk/gcc/tree.c
===================================================================
--- trunk.orig/gcc/tree.c	2011-08-18 13:19:16.000000000 +0200
+++ trunk/gcc/tree.c	2011-08-18 13:17:45.000000000 +0200
@@ -6505,21 +6505,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;
+  unsigned bitno = TYPE_PRECISION (TREE_TYPE (t)) - 1;
+  unsigned HOST_WIDE_INT w;
 
-  /* 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;
+  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.
Index: trunk/gcc/tree-ssa-loop-ivopts.c
===================================================================
--- trunk.orig/gcc/tree-ssa-loop-ivopts.c	2011-08-18 10:35:13.000000000 +0200
+++ trunk/gcc/tree-ssa-loop-ivopts.c	2011-08-18 13:17:48.000000000 +0200
@@ -2892,26 +2892,6 @@  var_at_stmt (struct loop *loop, struct i
     return cand->var_before;
 }
 
-/* Return the most significant (sign) bit of T.  Similar to tree_int_cst_msb,
-   but the bit is determined from TYPE_PRECISION, not MODE_BITSIZE.  */
-
-int
-tree_int_cst_sign_bit (const_tree t)
-{
-  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;
-}
-
 /* If A is (TYPE) BA and B is (TYPE) BB, and the types of BA and BB have the
    same precision that is at least as wide as the precision of TYPE, stores
    BA to A and BB to B, and returns the type of BA.  Otherwise, returns the
Index: trunk/gcc/tree.h
===================================================================
--- trunk.orig/gcc/tree.h	2011-08-18 10:35:13.000000000 +0200
+++ trunk/gcc/tree.h	2011-08-18 13:16:47.000000000 +0200
@@ -4380,7 +4380,6 @@  tree_low_cst (const_tree t, int pos)
   return TREE_INT_CST_LOW (t);
 }
 #endif
-extern int tree_int_cst_msb (const_tree);
 extern int tree_int_cst_sgn (const_tree);
 extern int tree_int_cst_sign_bit (const_tree);
 extern unsigned int tree_int_cst_min_precision (tree, bool);