summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2007-01-28 05:04:48 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2007-01-28 05:04:48 +0000
commit426a138f1f231a55f4670be9c4bca30dbb0e3b61 (patch)
treed5119687bedfd7a7f56d6218696508ae430f8416 /gcc
parent6117e4152254104e118e366d56afdfcc83e2b473 (diff)
downloadgcc-426a138f1f231a55f4670be9c4bca30dbb0e3b61.tar.gz
* tree.c (tree_fold_gcd): Delete.
* tree.h (tree_fold_gcd): Remove prototype. * tree-data-ref.c (tree_fold_divides_p): Don't use tree_fold_gcd to test whether one constant integer is a multiple of another. Instead call int_const_binop with TRUNC_MOD_EXPR and test for a zero result. * fold-const.c (multiple_of_p): We've determined both TOP and BOTTOM are integer constants so we can call int_const_binop directly instead of the more generic const_binop. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121253 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/fold-const.c4
-rw-r--r--gcc/tree-data-ref.c8
-rw-r--r--gcc/tree.c38
-rw-r--r--gcc/tree.h1
5 files changed, 17 insertions, 45 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2f0b43957c7..6d3de89adaa 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,16 @@
2007-01-27 Roger Sayle <roger@eyesopen.com>
+ * tree.c (tree_fold_gcd): Delete.
+ * tree.h (tree_fold_gcd): Remove prototype.
+ * tree-data-ref.c (tree_fold_divides_p): Don't use tree_fold_gcd to
+ test whether one constant integer is a multiple of another. Instead
+ call int_const_binop with TRUNC_MOD_EXPR and test for a zero result.
+ * fold-const.c (multiple_of_p): We've determined both TOP and
+ BOTTOM are integer constants so we can call int_const_binop directly
+ instead of the more generic const_binop.
+
+2007-01-27 Roger Sayle <roger@eyesopen.com>
+
* fold-const.c (size_binop): In the fast-paths for X+0, 0+X, X-0 and
1*X check that the constant hasn't overflowed, to preserve the
TREE_OVERFLOW bit.
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index b6065871ffd..34ff7111072 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -12527,8 +12527,8 @@ multiple_of_p (tree type, tree top, tree bottom)
&& (tree_int_cst_sgn (top) < 0
|| tree_int_cst_sgn (bottom) < 0)))
return 0;
- return integer_zerop (const_binop (TRUNC_MOD_EXPR,
- top, bottom, 0));
+ return integer_zerop (int_const_binop (TRUNC_MOD_EXPR,
+ top, bottom, 0));
default:
return 0;
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 2da59db43ff..d6201b6cf60 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -561,11 +561,11 @@ base_addr_differ_p (struct data_reference *dra,
/* Returns true iff A divides B. */
static inline bool
-tree_fold_divides_p (tree a,
- tree b)
+tree_fold_divides_p (tree a, tree b)
{
- /* Determines whether (A == gcd (A, B)). */
- return tree_int_cst_equal (a, tree_fold_gcd (a, b));
+ gcc_assert (TREE_CODE (a) == INTEGER_CST);
+ gcc_assert (TREE_CODE (b) == INTEGER_CST);
+ return integer_zerop (int_const_binop (TRUNC_MOD_EXPR, b, a, 0));
}
/* Returns true iff A divides B. */
diff --git a/gcc/tree.c b/gcc/tree.c
index ea462f027d3..6824c14d16c 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -7465,44 +7465,6 @@ int_cst_value (tree x)
return val;
}
-/* Returns the greatest common divisor of A and B, which must be
- INTEGER_CSTs. */
-
-tree
-tree_fold_gcd (tree a, tree b)
-{
- tree a_mod_b;
- tree type = TREE_TYPE (a);
-
- gcc_assert (TREE_CODE (a) == INTEGER_CST);
- gcc_assert (TREE_CODE (b) == INTEGER_CST);
-
- if (integer_zerop (a))
- return b;
-
- if (integer_zerop (b))
- return a;
-
- if (tree_int_cst_sgn (a) == -1)
- a = fold_build2 (MULT_EXPR, type, a,
- build_int_cst (type, -1));
-
- if (tree_int_cst_sgn (b) == -1)
- b = fold_build2 (MULT_EXPR, type, b,
- build_int_cst (type, -1));
-
- while (1)
- {
- a_mod_b = fold_build2 (FLOOR_MOD_EXPR, type, a, b);
-
- if (!TREE_INT_CST_LOW (a_mod_b)
- && !TREE_INT_CST_HIGH (a_mod_b))
- return b;
-
- a = b;
- b = a_mod_b;
- }
-}
/* Returns unsigned variant of TYPE. */
diff --git a/gcc/tree.h b/gcc/tree.h
index cbb47cc8489..ddb7e6af24d 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -4454,7 +4454,6 @@ extern void build_common_builtin_nodes (void);
extern tree build_nonstandard_integer_type (unsigned HOST_WIDE_INT, int);
extern tree build_range_type (tree, tree, tree);
extern HOST_WIDE_INT int_cst_value (tree);
-extern tree tree_fold_gcd (tree, tree);
extern tree build_addr (tree, tree);
extern bool fields_compatible_p (tree, tree);