From b0eb889bf88eff3316690c6397a7f3dc75fbeda7 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 31 Aug 2015 16:02:00 +0200 Subject: Move some comparison simplifications to match.pd 2015-08-31 Marc Glisse 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. From-SVN: r227346 --- gcc/tree.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gcc/tree.c') diff --git a/gcc/tree.c b/gcc/tree.c index af3a6a3..ed64fe7 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); -- cgit v1.1