]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc/
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Nov 2013 14:50:47 +0000 (14:50 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Nov 2013 14:50:47 +0000 (14:50 +0000)
* tree.h (tree_fits_shwi_p, tree_fits_uhwi_p): Declare.
* tree.c (tree_fits_shwi_p, tree_fits_uhwi_p): Define.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204954 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree.c
gcc/tree.h

index 2ed1b63f989ed4f293072b20d531077acab3d84a..6ae3a6faf7ff9ad148d7e4e174e99bfc960017ea 100644 (file)
@@ -1,3 +1,8 @@
+2013-11-18  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * tree.h (tree_fits_shwi_p, tree_fits_uhwi_p): Declare.
+       * tree.c (tree_fits_shwi_p, tree_fits_uhwi_p): Define.
+
 2013-11-18  Kirill Yukhin  <kirill.yukhin@intel.com>
 
        * gcc/config/ia64/ia64.c (ia64_split_tmode_move): Mark
index 34bc8ac73a54814611f5a631ba9f60ebdd1c5dc3..374f560817e1cd7ebed916737a1964f7550e4692 100644 (file)
@@ -6990,6 +6990,32 @@ host_integerp (const_tree t, int pos)
              || (pos && TREE_INT_CST_HIGH (t) == 0)));
 }
 
+/* Return true if T is an INTEGER_CST whose numerical value (extended
+   according to TYPE_UNSIGNED) fits in a signed HOST_WIDE_INT.  */
+
+bool
+tree_fits_shwi_p (const_tree t)
+{
+  return (t != NULL_TREE
+         && TREE_CODE (t) == INTEGER_CST
+         && ((TREE_INT_CST_HIGH (t) == 0
+              && (HOST_WIDE_INT) TREE_INT_CST_LOW (t) >= 0)
+             || (TREE_INT_CST_HIGH (t) == -1
+                 && (HOST_WIDE_INT) TREE_INT_CST_LOW (t) < 0
+                 && !TYPE_UNSIGNED (TREE_TYPE (t)))));
+}
+
+/* Return true if T is an INTEGER_CST whose numerical value (extended
+   according to TYPE_UNSIGNED) fits in an unsigned HOST_WIDE_INT.  */
+
+bool
+tree_fits_uhwi_p (const_tree t)
+{
+  return (t != NULL_TREE
+         && TREE_CODE (t) == INTEGER_CST
+         && TREE_INT_CST_HIGH (t) == 0);
+}
+
 /* Return the HOST_WIDE_INT least significant bits of T if it is an
    INTEGER_CST and there is no overflow.  POS is nonzero if the result must
    be non-negative.  We must be able to satisfy the above conditions.  */
index dee15be7321db25537cfce39092f97428d43c4ff..59da1619aa6f0fc22ed2a8b55ec69de19916b9be 100644 (file)
@@ -3662,6 +3662,16 @@ extern int host_integerp (const_tree, int)
   ATTRIBUTE_PURE /* host_integerp is pure only when checking is disabled.  */
 #endif
   ;
+extern bool tree_fits_shwi_p (const_tree)
+#ifndef ENABLE_TREE_CHECKING
+  ATTRIBUTE_PURE /* tree_fits_shwi_p is pure only when checking is disabled.  */
+#endif
+  ;
+extern bool tree_fits_uhwi_p (const_tree)
+#ifndef ENABLE_TREE_CHECKING
+  ATTRIBUTE_PURE /* tree_fits_uhwi_p is pure only when checking is disabled.  */
+#endif
+  ;
 extern HOST_WIDE_INT tree_low_cst (const_tree, int);
 #if !defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 4003)
 extern inline __attribute__ ((__gnu_inline__)) HOST_WIDE_INT