summaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorglisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4>2015-08-31 14:02:00 +0000
committerglisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4>2015-08-31 14:02:00 +0000
commit06e4870e3d20bb71848afa16d4e9fac4224fa7ba (patch)
treea33c135ce9d2d8750a86956b05a1741e6d13de2e /gcc/tree.c
parent5a7d537d7b3b9c218e8579d9dc6d57a45fc0d2ea (diff)
downloadgcc-06e4870e3d20bb71848afa16d4e9fac4224fa7ba.tar.gz
Move some comparison simplifications to match.pd
2015-08-31 Marc Glisse <marc.glisse@inria.fr> gcc/ * tree.h (zerop): New function. * tree.c (zerop): Likewise. (element_precision): Handle expressions. * match.pd (define_predicates): Add zerop. (x <= +Inf): Fix comment. (abs (x) == 0, A & C == C, A & C != 0): Converted from ... * fold-const.c (fold_binary_loc): ... here. Remove. gcc/testsuite/ * gcc.dg/tree-ssa/cmp-1.c: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227346 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index af3a6a340e4..ed64fe7d273 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -2215,6 +2215,17 @@ grow_tree_vec_stat (tree v, int len MEM_STAT_DECL)
return v;
}
+/* Return 1 if EXPR is the constant zero, whether it is integral, float or
+ fixed, and scalar, complex or vector. */
+
+int
+zerop (const_tree expr)
+{
+ return (integer_zerop (expr)
+ || real_zerop (expr)
+ || fixed_zerop (expr));
+}
+
/* Return 1 if EXPR is the integer constant zero or a complex constant
of zero. */
@@ -7512,6 +7523,8 @@ valid_constant_size_p (const_tree size)
unsigned int
element_precision (const_tree type)
{
+ if (!TYPE_P (type))
+ type = TREE_TYPE (type);
enum tree_code code = TREE_CODE (type);
if (code == COMPLEX_TYPE || code == VECTOR_TYPE)
type = TREE_TYPE (type);