diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2013-05-06 23:14:59 +0200 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2013-05-06 21:14:59 +0000 |
commit | 9a0ee7b0286f1de2f05a5e4e41f8c3436053c975 (patch) | |
tree | 7d9d8b97ec358bd6267025f8446e73231ebbc98e /gcc | |
parent | 6698175d1591c25041f3979a5c01ef5f81e2f4ff (diff) | |
download | gcc-9a0ee7b0286f1de2f05a5e4e41f8c3436053c975.zip gcc-9a0ee7b0286f1de2f05a5e4e41f8c3436053c975.tar.gz gcc-9a0ee7b0286f1de2f05a5e4e41f8c3436053c975.tar.bz2 |
tree.c (integer_all_onesp): Test that both components are all 1s.
2013-05-06 Marc Glisse <marc.glisse@inria.fr>
* tree.c (integer_all_onesp) <COMPLEX_CST>: Test that both
components are all 1s.
(integer_minus_onep): New function.
* tree.h (integer_minus_onep): Declare it.
* fold-const.c (fold_binary_loc) <MULT_EXPR>: Test
integer_minus_onep instead of integer_all_onesp.
From-SVN: r198649
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/fold-const.c | 2 | ||||
-rw-r--r-- | gcc/tree.c | 18 | ||||
-rw-r--r-- | gcc/tree.h | 5 |
4 files changed, 31 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 09108c3..d813433 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2013-05-06 Marc Glisse <marc.glisse@inria.fr> + + * tree.c (integer_all_onesp) <COMPLEX_CST>: Test that both + components are all 1s. + (integer_minus_onep): New function. + * tree.h (integer_minus_onep): Declare it. + * fold-const.c (fold_binary_loc) <MULT_EXPR>: Test + integer_minus_onep instead of integer_all_onesp. + 2013-05-06 Oleg Endo <olegendo@gcc.gnu.org> PR target/52933 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index f93ce8a..74b451e 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -10870,7 +10870,7 @@ fold_binary_loc (location_t loc, /* Transform x * -1 into -x. Make sure to do the negation on the original operand with conversions not stripped because we can only strip non-sign-changing conversions. */ - if (integer_all_onesp (arg1)) + if (integer_minus_onep (arg1)) return fold_convert_loc (loc, type, negate_expr (op0)); /* Transform x * -C into -x * C if x is easily negatable. */ if (TREE_CODE (arg1) == INTEGER_CST @@ -1781,7 +1781,7 @@ integer_onep (const_tree expr) } /* Return 1 if EXPR is an integer containing all 1's in as much precision as - it contains. Likewise for the corresponding complex constant. */ + it contains, or a complex or vector whose subparts are such integers. */ int integer_all_onesp (const_tree expr) @@ -1793,7 +1793,7 @@ integer_all_onesp (const_tree expr) if (TREE_CODE (expr) == COMPLEX_CST && integer_all_onesp (TREE_REALPART (expr)) - && integer_zerop (TREE_IMAGPART (expr))) + && integer_all_onesp (TREE_IMAGPART (expr))) return 1; else if (TREE_CODE (expr) == VECTOR_CST) @@ -1839,6 +1839,20 @@ integer_all_onesp (const_tree expr) return TREE_INT_CST_LOW (expr) == ((unsigned HOST_WIDE_INT) 1 << prec) - 1; } +/* Return 1 if EXPR is the integer constant minus one. */ + +int +integer_minus_onep (const_tree expr) +{ + STRIP_NOPS (expr); + + if (TREE_CODE (expr) == COMPLEX_CST) + return (integer_all_onesp (TREE_REALPART (expr)) + && integer_zerop (TREE_IMAGPART (expr))); + else + return integer_all_onesp (expr); +} + /* Return 1 if EXPR is an integer constant that is a power of 2 (i.e., has only one bit on). */ @@ -5310,6 +5310,11 @@ extern int integer_onep (const_tree); extern int integer_all_onesp (const_tree); +/* integer_minus_onep (tree x) is nonzero if X is an integer constant of + value -1. */ + +extern int integer_minus_onep (const_tree); + /* integer_pow2p (tree x) is nonzero is X is an integer constant with exactly one bit 1. */ |