]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
(tree_int_cst_sgn): New function.
authorRichard Kenner <kenner@gcc.gnu.org>
Mon, 14 Mar 1994 10:07:30 +0000 (05:07 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Mon, 14 Mar 1994 10:07:30 +0000 (05:07 -0500)
From-SVN: r6774

gcc/tree.c

index d75419432885c8d4f70f49159837528e88d70c9e..23076d6938896c878ba6f973609259c1b68f4cc3 100644 (file)
@@ -2985,6 +2985,24 @@ tree_int_cst_lt (t1, t2)
   return INT_CST_LT_UNSIGNED (t1, t2);
 }
 
+/* Return an indication of the sign of the integer constant T.
+   The return value is -1 if T < 0, 0 if T == 0, and 1 if T > 0.
+   Note that -1 will never be returned it T's type is unsigned.  */
+
+int
+tree_int_cst_sgn (t)
+     tree t;
+{
+  if (TREE_INT_CST_LOW (t) == 0 && TREE_INT_CST_HIGH (t) == 0)
+    return 0;
+  else if (TREE_UNSIGNED (TREE_TYPE (t)))
+    return 1;
+  else if (TREE_INT_CST_HIGH (t) < 0)
+    return -1;
+  else
+    return 1;
+}
+
 /* Compare two constructor-element-type constants.  */
 int
 simple_cst_list_equal (l1, l2)