From: Jakub Jelinek Date: Thu, 10 Apr 2014 09:35:39 +0000 (+0200) Subject: backport: re PR tree-optimization/60502 (ICE reassociation and vector types.) X-Git-Tag: releases/gcc-4.8.3~149 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=141982d4d4b169c0c42127ab81a38d04337442c0;p=thirdparty%2Fgcc.git backport: re PR tree-optimization/60502 (ICE reassociation and vector types.) Backport from mainline 2014-03-12 Jakub Jelinek Marc Glisse PR tree-optimization/60502 * tree-ssa-reassoc.c (eliminate_not_pairs): Use build_all_ones_cst instead of build_low_bits_mask. * gcc.c-torture/compile/pr60502.c: New test. 2013-06-13 Marc Glisse * tree.c (build_all_ones_cst): New function. * tree.h (build_all_ones_cst): Declare it. 2013-05-10 Marc Glisse * tree.c (build_minus_one_cst): New function. * tree.h (build_minus_one_cst): Declare new function. From-SVN: r209274 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4c6daa9ce7e5..e6fd9b670883 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,23 @@ +2014-04-10 Jakub Jelinek + + Backport from mainline + 2014-03-12 Jakub Jelinek + Marc Glisse + + PR tree-optimization/60502 + * tree-ssa-reassoc.c (eliminate_not_pairs): Use build_all_ones_cst + instead of build_low_bits_mask. + + 2013-06-13 Marc Glisse + + * tree.c (build_all_ones_cst): New function. + * tree.h (build_all_ones_cst): Declare it. + + 2013-05-10 Marc Glisse + + * tree.c (build_minus_one_cst): New function. + * tree.h (build_minus_one_cst): Declare new function. + 2014-04-10 Jakub Jelinek Backport from mainline diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d94f2a510789..2fe4b2b83e19 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,12 @@ 2014-04-10 Jakub Jelinek Backport from mainline + 2014-03-12 Jakub Jelinek + Marc Glisse + + PR tree-optimization/60502 + * gcc.c-torture/compile/pr60502.c: New test. + 2014-03-28 Jakub Jelinek PR target/60693 diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 14eae6b3f7b0..b3528391b857 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -785,8 +785,7 @@ eliminate_not_pairs (enum tree_code opcode, if (opcode == BIT_AND_EXPR) oe->op = build_zero_cst (TREE_TYPE (oe->op)); else if (opcode == BIT_IOR_EXPR) - oe->op = build_low_bits_mask (TREE_TYPE (oe->op), - TYPE_PRECISION (TREE_TYPE (oe->op))); + oe->op = build_all_ones_cst (TREE_TYPE (oe->op)); reassociate_stats.ops_eliminated += ops->length () - 1; ops->truncate (0); diff --git a/gcc/tree.c b/gcc/tree.c index 9075664954c4..006c48134d4e 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1619,6 +1619,60 @@ build_one_cst (tree type) } } +/* Return an integer of type TYPE containing all 1's in as much precision as + it contains, or a complex or vector whose subparts are such integers. */ + +tree +build_all_ones_cst (tree type) +{ + if (TREE_CODE (type) == COMPLEX_TYPE) + { + tree scalar = build_all_ones_cst (TREE_TYPE (type)); + return build_complex (type, scalar, scalar); + } + else + return build_minus_one_cst (type); +} + +/* Return a constant of arithmetic type TYPE which is the + opposite of the multiplicative identity of the set TYPE. */ + +tree +build_minus_one_cst (tree type) +{ + switch (TREE_CODE (type)) + { + case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: + case POINTER_TYPE: case REFERENCE_TYPE: + case OFFSET_TYPE: + return build_int_cst (type, -1); + + case REAL_TYPE: + return build_real (type, dconstm1); + + case FIXED_POINT_TYPE: + /* We can only generate 1 for accum types. */ + gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type))); + return build_fixed (type, fixed_from_double_int (double_int_minus_one, + TYPE_MODE (type))); + + case VECTOR_TYPE: + { + tree scalar = build_minus_one_cst (TREE_TYPE (type)); + + return build_vector_from_val (type, scalar); + } + + case COMPLEX_TYPE: + return build_complex (type, + build_minus_one_cst (TREE_TYPE (type)), + build_zero_cst (TREE_TYPE (type))); + + default: + gcc_unreachable (); + } +} + /* Build 0 constant of type TYPE. This is used by constructor folding and thus the constant should be represented in memory by zero(es). */ diff --git a/gcc/tree.h b/gcc/tree.h index 2b93882d2167..33d8c5d8be1c 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4760,6 +4760,8 @@ extern tree build_constructor_from_list (tree, tree); extern tree build_real_from_int_cst (tree, const_tree); extern tree build_complex (tree, tree, tree); extern tree build_one_cst (tree); +extern tree build_minus_one_cst (tree); +extern tree build_all_ones_cst (tree); extern tree build_zero_cst (tree); extern tree build_string (int, const char *); extern tree build_tree_list_stat (tree, tree MEM_STAT_DECL);