diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2014-11-18 11:26:31 +0100 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2014-11-18 10:26:31 +0000 |
commit | 092404511f58ed2a7c11785fa5b2e69b32048fd3 (patch) | |
tree | c1395e2804b0507497743d4f678303c275f80e85 /gcc/tree.c | |
parent | 9f37760abed226a27061ded75d50be803ef73a96 (diff) | |
download | gcc-092404511f58ed2a7c11785fa5b2e69b32048fd3.zip gcc-092404511f58ed2a7c11785fa5b2e69b32048fd3.tar.gz gcc-092404511f58ed2a7c11785fa5b2e69b32048fd3.tar.bz2 |
tree.c (element_mode, [...]): New functions.
2014-11-18 Marc Glisse <marc.glisse@inria.fr>
* tree.c (element_mode, integer_truep): New functions.
* tree.h (element_mode, integer_truep): Declare them.
* fold-const.c (negate_expr_p, fold_negate_expr, combine_comparisons,
fold_cond_expr_with_comparison, fold_real_zero_addition_p,
fold_comparison, fold_ternary_loc, tree_call_nonnegative_warnv_p,
fold_strip_sign_ops): Use element_mode.
(fold_binary_loc): Use element_mode and element_precision.
* match.pd: Use integer_truep, element_mode, element_precision,
VECTOR_TYPE_P and build_one_cst. Extend some transformations to
vectors. Simplify A/-A.
From-SVN: r217702
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -2275,6 +2275,20 @@ integer_nonzerop (const_tree expr) || integer_nonzerop (TREE_IMAGPART (expr))))); } +/* Return 1 if EXPR is the integer constant one. For vector, + return 1 if every piece is the integer constant minus one + (representing the value TRUE). */ + +int +integer_truep (const_tree expr) +{ + STRIP_NOPS (expr); + + if (TREE_CODE (expr) == VECTOR_CST) + return integer_all_onesp (expr); + return integer_onep (expr); +} + /* Return 1 if EXPR is the fixed-point constant zero. */ int @@ -12310,4 +12324,18 @@ get_base_address (tree t) return t; } +/* Return the machine mode of T. For vectors, returns the mode of the + inner type. The main use case is to feed the result to HONOR_NANS, + avoiding the BLKmode that a direct TYPE_MODE (T) might return. */ + +machine_mode +element_mode (const_tree t) +{ + if (!TYPE_P (t)) + t = TREE_TYPE (t); + if (VECTOR_TYPE_P (t) || TREE_CODE (t) == COMPLEX_TYPE) + t = TREE_TYPE (t); + return TYPE_MODE (t); +} + #include "gt-tree.h" |