diff options
author | glisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-07-06 18:19:41 +0000 |
---|---|---|
committer | glisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-07-06 18:19:41 +0000 |
commit | c8047e010e0bac287b0d00585a81fba4bead8659 (patch) | |
tree | 9b00cc78be393b3fe6c2a7993ef46913e3db86b8 | |
parent | 3c537ec79cfcf161cf699fd32af9d872eed58886 (diff) | |
download | gcc-c8047e010e0bac287b0d00585a81fba4bead8659.tar.gz |
2015-07-06 Marc Glisse <marc.glisse@inria.fr>
* match.pd: Remove element_mode inside HONOR_*.
(~ (-A) -> A - 1, ~ (A - 1) -> -A): Handle complex types.
(~X | X -> -1, ~X ^ X -> -1): Merge.
* tree.c (build_each_one_cst): New function.
* tree.h (build_each_one_cst): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225473 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/match.pd | 36 | ||||
-rw-r--r-- | gcc/tree.c | 15 | ||||
-rw-r--r-- | gcc/tree.h | 1 |
4 files changed, 41 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7c73d50d052..2eeb6c555a9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-07-06 Marc Glisse <marc.glisse@inria.fr> + + * match.pd: Remove element_mode inside HONOR_*. + (~ (-A) -> A - 1, ~ (A - 1) -> -A): Handle complex types. + (~X | X -> -1, ~X ^ X -> -1): Merge. + * tree.c (build_each_one_cst): New function. + * tree.h (build_each_one_cst): Likewise. + 2015-07-06 Steve Ellcey <sellcey@imgtec.com> * config.gcc <mips*-*-*>: Add fused-madd.opt. diff --git a/gcc/match.pd b/gcc/match.pd index f850d523265..53e911a20aa 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -101,23 +101,23 @@ along with GCC; see the file COPYING3. If not see negative value by 0 gives -0, not +0. */ (simplify (mult @0 real_zerop@1) - (if (!HONOR_NANS (type) && !HONOR_SIGNED_ZEROS (element_mode (type))) + (if (!HONOR_NANS (type) && !HONOR_SIGNED_ZEROS (type)) @1)) /* In IEEE floating point, x*1 is not equivalent to x for snans. Likewise for complex arithmetic with signed zeros. */ (simplify (mult @0 real_onep) - (if (!HONOR_SNANS (element_mode (type)) - && (!HONOR_SIGNED_ZEROS (element_mode (type)) + (if (!HONOR_SNANS (type) + && (!HONOR_SIGNED_ZEROS (type) || !COMPLEX_FLOAT_TYPE_P (type))) (non_lvalue @0))) /* Transform x * -1.0 into -x. */ (simplify (mult @0 real_minus_onep) - (if (!HONOR_SNANS (element_mode (type)) - && (!HONOR_SIGNED_ZEROS (element_mode (type)) + (if (!HONOR_SNANS (type) + && (!HONOR_SIGNED_ZEROS (type) || !COMPLEX_FLOAT_TYPE_P (type))) (negate @0))) @@ -165,7 +165,7 @@ along with GCC; see the file COPYING3. If not see (rdiv @0 @0) (if (FLOAT_TYPE_P (type) && ! HONOR_NANS (type) - && ! HONOR_INFINITIES (element_mode (type))) + && ! HONOR_INFINITIES (type)) { build_one_cst (type); })) /* Optimize -A / A to -1.0 if we don't care about @@ -174,19 +174,19 @@ along with GCC; see the file COPYING3. If not see (rdiv:c @0 (negate @0)) (if (FLOAT_TYPE_P (type) && ! HONOR_NANS (type) - && ! HONOR_INFINITIES (element_mode (type))) + && ! HONOR_INFINITIES (type)) { build_minus_one_cst (type); })) /* In IEEE floating point, x/1 is not equivalent to x for snans. */ (simplify (rdiv @0 real_onep) - (if (!HONOR_SNANS (element_mode (type))) + (if (!HONOR_SNANS (type)) (non_lvalue @0))) /* In IEEE floating point, x/-1 is not equivalent to -x for snans. */ (simplify (rdiv @0 real_minus_onep) - (if (!HONOR_SNANS (element_mode (type))) + (if (!HONOR_SNANS (type)) (negate @0))) /* If ARG1 is a constant, we can convert this to a multiply by the @@ -297,9 +297,12 @@ along with GCC; see the file COPYING3. If not see @1) /* ~x | x -> -1 */ -(simplify - (bit_ior:c (convert? @0) (convert? (bit_not @0))) - (convert { build_all_ones_cst (TREE_TYPE (@0)); })) +/* ~x ^ x -> -1 */ +/* ~x + x -> -1 */ +(for op (bit_ior bit_xor plus) + (simplify + (op:c (convert? @0) (convert? (bit_not @0))) + (convert { build_all_ones_cst (TREE_TYPE (@0)); }))) /* x ^ x -> 0 */ (simplify @@ -311,11 +314,6 @@ along with GCC; see the file COPYING3. If not see (bit_xor @0 integer_all_onesp@1) (bit_not @0)) -/* ~X ^ X is -1. */ -(simplify - (bit_xor:c (bit_not @0) @0) - { build_all_ones_cst (type); }) - /* x & ~0 -> x */ (simplify (bit_and @0 integer_all_onesp) @@ -604,11 +602,11 @@ along with GCC; see the file COPYING3. If not see (simplify (bit_not (convert? (negate @0))) (if (tree_nop_conversion_p (type, TREE_TYPE (@0))) - (convert (minus @0 { build_one_cst (TREE_TYPE (@0)); })))) + (convert (minus @0 { build_each_one_cst (TREE_TYPE (@0)); })))) /* Convert ~ (A - 1) or ~ (A + -1) to -A. */ (simplify - (bit_not (convert? (minus @0 integer_onep))) + (bit_not (convert? (minus @0 integer_each_onep))) (if (tree_nop_conversion_p (type, TREE_TYPE (@0))) (convert (negate @0)))) (simplify diff --git a/gcc/tree.c b/gcc/tree.c index 6628a387f62..c0e2b0a2f13 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1968,6 +1968,21 @@ build_complex (tree type, tree real, tree imag) return t; } +/* Return the constant 1 in type TYPE. If TYPE has several elements, each + element is set to 1. In particular, this is 1 + i for complex types. */ + +tree +build_each_one_cst (tree type) +{ + if (TREE_CODE (type) == COMPLEX_TYPE) + { + tree scalar = build_one_cst (TREE_TYPE (type)); + return build_complex (type, scalar, scalar); + } + else + return build_one_cst (type); +} + /* Return a constant of arithmetic type TYPE which is the multiplicative identity of the set TYPE. */ diff --git a/gcc/tree.h b/gcc/tree.h index 250f99d14b3..6df22177fc2 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -3772,6 +3772,7 @@ extern tree build_constructor_from_list (tree, tree); extern tree build_constructor_va (tree, int, ...); extern tree build_real_from_int_cst (tree, const_tree); extern tree build_complex (tree, tree, tree); +extern tree build_each_one_cst (tree); extern tree build_one_cst (tree); extern tree build_minus_one_cst (tree); extern tree build_all_ones_cst (tree); |