diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1994-03-14 05:07:30 -0500 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1994-03-14 05:07:30 -0500 |
commit | 6d9cb074bfb64a74b0e4b64932093bde27cb3830 (patch) | |
tree | f68dd289de52e8a11af078444c7f1b557aed3c5e | |
parent | 40c9a5496ff759cedcebdc751e6e8a885c356454 (diff) | |
download | gcc-6d9cb074bfb64a74b0e4b64932093bde27cb3830.zip gcc-6d9cb074bfb64a74b0e4b64932093bde27cb3830.tar.gz gcc-6d9cb074bfb64a74b0e4b64932093bde27cb3830.tar.bz2 |
(tree_int_cst_sgn): New function.
From-SVN: r6774
-rw-r--r-- | gcc/tree.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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) |