From fca65709f76de207bd4140625237ddf5b539979f Mon Sep 17 00:00:00 2001 From: yroux Date: Tue, 22 Apr 2014 14:15:34 +0000 Subject: [PATCH] Merge branches/gcc-4_9-branch up to rev 209633 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/linaro@209635 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc-4_9-branch/gcc/BASE-VER | 2 +- gcc-4_9-branch/gcc/ChangeLog | 94 +++++++++++ gcc-4_9-branch/gcc/DEV-PHASE | 1 + gcc-4_9-branch/gcc/asan.c | 15 ++ gcc-4_9-branch/gcc/c-family/ChangeLog | 10 ++ gcc-4_9-branch/gcc/c-family/c-common.c | 15 +- gcc-4_9-branch/gcc/cfgexpand.c | 18 +- gcc-4_9-branch/gcc/fold-const.c | 4 - gcc-4_9-branch/gcc/graphite-scop-detection.c | 11 +- gcc-4_9-branch/gcc/omp-low.c | 110 +++++++++---- gcc-4_9-branch/gcc/testsuite/ChangeLog | 65 ++++++++ .../gcc/testsuite/c-c++-common/gomp/pr60823-1.c | 19 +++ .../gcc/testsuite/c-c++-common/gomp/pr60823-2.c | 43 +++++ .../gcc/testsuite/c-c++-common/gomp/pr60823-3.c | 32 ++++ gcc-4_9-branch/gcc/testsuite/g++.dg/opt/pr60849.C | 13 ++ .../gcc/testsuite/g++.dg/vect/pr60836.cc | 39 +++++ .../gcc/testsuite/gcc.dg/graphite/pr55022.c | 27 +++ .../gcc/testsuite/gcc.dg/graphite/pr59817-1.c | 16 ++ .../gcc/testsuite/gcc.dg/graphite/pr59817-2.c | 15 ++ gcc-4_9-branch/gcc/testsuite/gcc.dg/pr60844.c | 16 ++ gcc-4_9-branch/gcc/testsuite/gcc.dg/vect/pr60841.c | 183 +++++++++++++++++++++ .../gcc/testsuite/gcc.target/i386/vec-may_alias.c | 25 +++ .../gcc/testsuite/gfortran.dg/graphite/pr59817.f | 14 ++ gcc-4_9-branch/gcc/tree-dfa.c | 2 +- gcc-4_9-branch/gcc/tree-ssa-propagate.c | 12 +- gcc-4_9-branch/gcc/tree-ssa-reassoc.c | 39 ++++- gcc-4_9-branch/gcc/tree-vect-data-refs.c | 8 +- gcc-4_9-branch/gcc/tree-vect-loop.c | 13 +- gcc-4_9-branch/gcc/tree-vect-slp.c | 42 +++-- gcc-4_9-branch/gcc/tree-vectorizer.h | 5 +- 30 files changed, 841 insertions(+), 67 deletions(-) create mode 100644 gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-1.c create mode 100644 gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-2.c create mode 100644 gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-3.c create mode 100644 gcc-4_9-branch/gcc/testsuite/g++.dg/opt/pr60849.C create mode 100644 gcc-4_9-branch/gcc/testsuite/g++.dg/vect/pr60836.cc create mode 100644 gcc-4_9-branch/gcc/testsuite/gcc.dg/graphite/pr55022.c create mode 100644 gcc-4_9-branch/gcc/testsuite/gcc.dg/graphite/pr59817-1.c create mode 100644 gcc-4_9-branch/gcc/testsuite/gcc.dg/graphite/pr59817-2.c create mode 100644 gcc-4_9-branch/gcc/testsuite/gcc.dg/pr60844.c create mode 100644 gcc-4_9-branch/gcc/testsuite/gcc.dg/vect/pr60841.c create mode 100644 gcc-4_9-branch/gcc/testsuite/gcc.target/i386/vec-may_alias.c create mode 100644 gcc-4_9-branch/gcc/testsuite/gfortran.dg/graphite/pr59817.f diff --git a/gcc-4_9-branch/gcc/BASE-VER b/gcc-4_9-branch/gcc/BASE-VER index 6ed7776bf32..5b341fd799e 100644 --- a/gcc-4_9-branch/gcc/BASE-VER +++ b/gcc-4_9-branch/gcc/BASE-VER @@ -1 +1 @@ -4.9.0 +4.9.1 diff --git a/gcc-4_9-branch/gcc/ChangeLog b/gcc-4_9-branch/gcc/ChangeLog index c0f56a156b0..3ac3c810c79 100644 --- a/gcc-4_9-branch/gcc/ChangeLog +++ b/gcc-4_9-branch/gcc/ChangeLog @@ -1,3 +1,97 @@ +2014-04-22 Richard Biener + + Backport from mainline + 2014-04-14 Richard Biener + + PR middle-end/55022 + * fold-const.c (negate_expr_p): Don't negate directional rounding + division. + (fold_negate_expr): Likewise. + +2014-04-22 Richard Biener + + Backport from mainline + 2014-04-17 Richard Biener + + PR middle-end/60849 + * tree-ssa-propagate.c (valid_gimple_rhs_p): Only allow effective + boolean results for comparisons. + +2014-04-22 Richard Biener + + Backport from mainline + 2014-04-17 Richard Biener + + PR tree-optimization/60841 + * tree-vect-data-refs.c (vect_analyze_data_refs): Count stmts. + * tree-vect-loop.c (vect_analyze_loop_2): Pass down number + of stmts to SLP build. + * tree-vect-slp.c (vect_slp_analyze_bb_1): Likewise. + (vect_analyze_slp): Likewise. + (vect_analyze_slp_instance): Likewise. + (vect_build_slp_tree): Limit overall SLP tree growth. + * tree-vectorizer.h (vect_analyze_data_refs, + vect_analyze_slp): Adjust prototypes. + +2014-04-22 Richard Biener + + Backport from mainline + 2014-04-17 Richard Biener + + PR tree-optimization/60836 + * tree-vect-loop.c (vect_create_epilog_for_reduction): Force + initial PHI args to be gimple values. + +2014-04-22 Richard Biener + + Backport from mainline + 2014-04-14 Richard Biener + + PR tree-optimization/59817 + PR tree-optimization/60453 + * graphite-scop-detection.c (graphite_can_represent_scev): Complete + recursion to catch all CHRECs in the scalar evolution and restrict + the predicate for the remains appropriately. + +2014-04-22 Jakub Jelinek + + PR tree-optimization/60823 + * omp-low.c (ipa_simd_modify_function_body): Go through + all SSA_NAMEs and for those refering to vector arguments + which are going to be replaced adjust SSA_NAME_VAR and, + if it is a default definition, change it into a non-default + definition assigned at the beginning of function from new_decl. + (ipa_simd_modify_stmt_ops): Rewritten. + * tree-dfa.c (set_ssa_default_def): When removing default def, + check for NULL loc instead of NULL *loc. + +2014-04-22 Lin Zuojian + + PR middle-end/60281 + * asan.c (asan_emit_stack_protection): Force the base to align to + appropriate bits if STRICT_ALIGNMENT. Set shadow_mem align to + appropriate bits if STRICT_ALIGNMENT. + * cfgexpand.c (expand_stack_vars): Set base_align appropriately + when asan is on. + (expand_used_vars): Leave a space in the stack frame for alignment + if STRICT_ALIGNMENT. + +2014-04-22 Jakub Jelinek + + Backported from mainline + 2014-04-16 Jakub Jelinek + + PR tree-optimization/60844 + * tree-ssa-reassoc.c (reassoc_remove_stmt): New function. + (propagate_op_to_single_use, remove_visited_stmt_chain, + linearize_expr, repropagate_negates, reassociate_bb): Use it + instead of gsi_remove. + +2014-04-22 Jakub Jelinek + + * BASE-VER: Set to 4.9.1. + * DEV-PHASE: Set to prerelease. + 2014-04-22 Release Manager * GCC 4.9.0 released. diff --git a/gcc-4_9-branch/gcc/DEV-PHASE b/gcc-4_9-branch/gcc/DEV-PHASE index e69de29bb2d..373fbc60bb9 100644 --- a/gcc-4_9-branch/gcc/DEV-PHASE +++ b/gcc-4_9-branch/gcc/DEV-PHASE @@ -0,0 +1 @@ +prerelease diff --git a/gcc-4_9-branch/gcc/asan.c b/gcc-4_9-branch/gcc/asan.c index 53992a81b18..28a476fe4dd 100644 --- a/gcc-4_9-branch/gcc/asan.c +++ b/gcc-4_9-branch/gcc/asan.c @@ -1017,8 +1017,17 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb, base_align_bias = ((asan_frame_size + alignb - 1) & ~(alignb - HOST_WIDE_INT_1)) - asan_frame_size; } + /* Align base if target is STRICT_ALIGNMENT. */ + if (STRICT_ALIGNMENT) + base = expand_binop (Pmode, and_optab, base, + gen_int_mode (-((GET_MODE_ALIGNMENT (SImode) + << ASAN_SHADOW_SHIFT) + / BITS_PER_UNIT), Pmode), NULL_RTX, + 1, OPTAB_DIRECT); + if (use_after_return_class == -1 && pbase) emit_move_insn (pbase, base); + base = expand_binop (Pmode, add_optab, base, gen_int_mode (base_offset - base_align_bias, Pmode), NULL_RTX, 1, OPTAB_DIRECT); @@ -1097,6 +1106,8 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb, && (ASAN_RED_ZONE_SIZE >> ASAN_SHADOW_SHIFT) == 4); shadow_mem = gen_rtx_MEM (SImode, shadow_base); set_mem_alias_set (shadow_mem, asan_shadow_set); + if (STRICT_ALIGNMENT) + set_mem_align (shadow_mem, (GET_MODE_ALIGNMENT (SImode))); prev_offset = base_offset; for (l = length; l; l -= 2) { @@ -1186,6 +1197,10 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb, shadow_mem = gen_rtx_MEM (BLKmode, shadow_base); set_mem_alias_set (shadow_mem, asan_shadow_set); + + if (STRICT_ALIGNMENT) + set_mem_align (shadow_mem, (GET_MODE_ALIGNMENT (SImode))); + prev_offset = base_offset; last_offset = base_offset; last_size = 0; diff --git a/gcc-4_9-branch/gcc/c-family/ChangeLog b/gcc-4_9-branch/gcc/c-family/ChangeLog index 805ba9ca8c7..3600df77d98 100644 --- a/gcc-4_9-branch/gcc/c-family/ChangeLog +++ b/gcc-4_9-branch/gcc/c-family/ChangeLog @@ -1,3 +1,13 @@ +2014-04-22 Richard Biener + + Backport from mainline + 2014-04-14 Richard Biener + Marc Glisse + + PR c/60819 + * c-common.c (convert_vector_to_pointer_for_subscript): Properly + apply may-alias the scalar pointer type when applicable. + 2014-04-22 Release Manager * GCC 4.9.0 released. diff --git a/gcc-4_9-branch/gcc/c-family/c-common.c b/gcc-4_9-branch/gcc/c-family/c-common.c index 03731b4b81f..f7f2bb3e30e 100644 --- a/gcc-4_9-branch/gcc/c-family/c-common.c +++ b/gcc-4_9-branch/gcc/c-family/c-common.c @@ -11770,8 +11770,21 @@ convert_vector_to_pointer_for_subscript (location_t loc, c_common_mark_addressable_vec (*vecp); type = build_qualified_type (TREE_TYPE (type), TYPE_QUALS (type)); - type = build_pointer_type (type); type1 = build_pointer_type (TREE_TYPE (*vecp)); + bool ref_all = TYPE_REF_CAN_ALIAS_ALL (type1); + if (!ref_all + && !DECL_P (*vecp)) + { + /* If the original vector isn't declared may_alias and it + isn't a bare vector look if the subscripting would + alias the vector we subscript, and if not, force ref-all. */ + alias_set_type vecset = get_alias_set (*vecp); + alias_set_type sset = get_alias_set (type); + if (!alias_sets_must_conflict_p (sset, vecset) + && !alias_set_subset_of (sset, vecset)) + ref_all = true; + } + type = build_pointer_type_for_mode (type, ptr_mode, ref_all); *vecp = build1 (ADDR_EXPR, type1, *vecp); *vecp = convert (type, *vecp); } diff --git a/gcc-4_9-branch/gcc/cfgexpand.c b/gcc-4_9-branch/gcc/cfgexpand.c index b7f63602d99..14511e137aa 100644 --- a/gcc-4_9-branch/gcc/cfgexpand.c +++ b/gcc-4_9-branch/gcc/cfgexpand.c @@ -1013,10 +1013,19 @@ expand_stack_vars (bool (*pred) (size_t), struct stack_vars_data *data) if (data->asan_base == NULL) data->asan_base = gen_reg_rtx (Pmode); base = data->asan_base; + + if (!STRICT_ALIGNMENT) + base_align = crtl->max_used_stack_slot_alignment; + else + base_align = MAX (crtl->max_used_stack_slot_alignment, + GET_MODE_ALIGNMENT (SImode) + << ASAN_SHADOW_SHIFT); } else - offset = alloc_stack_frame_space (stack_vars[i].size, alignb); - base_align = crtl->max_used_stack_slot_alignment; + { + offset = alloc_stack_frame_space (stack_vars[i].size, alignb); + base_align = crtl->max_used_stack_slot_alignment; + } } else { @@ -1845,6 +1854,11 @@ expand_used_vars (void) = alloc_stack_frame_space (redzonesz, ASAN_RED_ZONE_SIZE); data.asan_vec.safe_push (prev_offset); data.asan_vec.safe_push (offset); + /* Leave space for alignment if STRICT_ALIGNMENT. */ + if (STRICT_ALIGNMENT) + alloc_stack_frame_space ((GET_MODE_ALIGNMENT (SImode) + << ASAN_SHADOW_SHIFT) + / BITS_PER_UNIT, 1); var_end_seq = asan_emit_stack_protection (virtual_stack_vars_rtx, diff --git a/gcc-4_9-branch/gcc/fold-const.c b/gcc-4_9-branch/gcc/fold-const.c index 891c0d5151c..5c2bf256c2a 100644 --- a/gcc-4_9-branch/gcc/fold-const.c +++ b/gcc-4_9-branch/gcc/fold-const.c @@ -484,8 +484,6 @@ negate_expr_p (tree t) case TRUNC_DIV_EXPR: case ROUND_DIV_EXPR: - case FLOOR_DIV_EXPR: - case CEIL_DIV_EXPR: case EXACT_DIV_EXPR: /* In general we can't negate A / B, because if A is INT_MIN and B is 1, we may turn this into INT_MIN / -1 which is undefined @@ -682,8 +680,6 @@ fold_negate_expr (location_t loc, tree t) case TRUNC_DIV_EXPR: case ROUND_DIV_EXPR: - case FLOOR_DIV_EXPR: - case CEIL_DIV_EXPR: case EXACT_DIV_EXPR: /* In general we can't negate A / B, because if A is INT_MIN and B is 1, we may turn this into INT_MIN / -1 which is undefined diff --git a/gcc-4_9-branch/gcc/graphite-scop-detection.c b/gcc-4_9-branch/gcc/graphite-scop-detection.c index b5e4a8c8cb3..821f0846ef2 100644 --- a/gcc-4_9-branch/gcc/graphite-scop-detection.c +++ b/gcc-4_9-branch/gcc/graphite-scop-detection.c @@ -219,7 +219,14 @@ graphite_can_represent_scev (tree scev) switch (TREE_CODE (scev)) { + case NEGATE_EXPR: + case BIT_NOT_EXPR: + CASE_CONVERT: + case NON_LVALUE_EXPR: + return graphite_can_represent_scev (TREE_OPERAND (scev, 0)); + case PLUS_EXPR: + case POINTER_PLUS_EXPR: case MINUS_EXPR: return graphite_can_represent_scev (TREE_OPERAND (scev, 0)) && graphite_can_represent_scev (TREE_OPERAND (scev, 1)); @@ -241,13 +248,15 @@ graphite_can_represent_scev (tree scev) if (!evolution_function_right_is_integer_cst (scev) || !graphite_can_represent_init (scev)) return false; + return graphite_can_represent_scev (CHREC_LEFT (scev)); default: break; } /* Only affine functions can be represented. */ - if (!scev_is_linear_expression (scev)) + if (tree_contains_chrecs (scev, NULL) + || !scev_is_linear_expression (scev)) return false; return true; diff --git a/gcc-4_9-branch/gcc/omp-low.c b/gcc-4_9-branch/gcc/omp-low.c index 11bb2d35a15..69a7d7e7e2d 100644 --- a/gcc-4_9-branch/gcc/omp-low.c +++ b/gcc-4_9-branch/gcc/omp-low.c @@ -11291,45 +11291,53 @@ static tree ipa_simd_modify_stmt_ops (tree *tp, int *walk_subtrees, void *data) { struct walk_stmt_info *wi = (struct walk_stmt_info *) data; - if (!SSA_VAR_P (*tp)) + struct modify_stmt_info *info = (struct modify_stmt_info *) wi->info; + tree *orig_tp = tp; + if (TREE_CODE (*tp) == ADDR_EXPR) + tp = &TREE_OPERAND (*tp, 0); + struct ipa_parm_adjustment *cand = NULL; + if (TREE_CODE (*tp) == PARM_DECL) + cand = ipa_get_adjustment_candidate (&tp, NULL, info->adjustments, true); + else { - /* Make sure we treat subtrees as a RHS. This makes sure that - when examining the `*foo' in *foo=x, the `foo' get treated as - a use properly. */ - wi->is_lhs = false; - wi->val_only = true; if (TYPE_P (*tp)) *walk_subtrees = 0; - return NULL_TREE; } - struct modify_stmt_info *info = (struct modify_stmt_info *) wi->info; - struct ipa_parm_adjustment *cand - = ipa_get_adjustment_candidate (&tp, NULL, info->adjustments, true); - if (!cand) - return NULL_TREE; - - tree t = *tp; - tree repl = make_ssa_name (TREE_TYPE (t), NULL); - gimple stmt; - gimple_stmt_iterator gsi = gsi_for_stmt (info->stmt); - if (wi->is_lhs) + tree repl = NULL_TREE; + if (cand) + repl = unshare_expr (cand->new_decl); + else { - stmt = gimple_build_assign (unshare_expr (cand->new_decl), repl); - gsi_insert_after (&gsi, stmt, GSI_SAME_STMT); - SSA_NAME_DEF_STMT (repl) = info->stmt; + if (tp != orig_tp) + { + *walk_subtrees = 0; + bool modified = info->modified; + info->modified = false; + walk_tree (tp, ipa_simd_modify_stmt_ops, wi, wi->pset); + if (!info->modified) + { + info->modified = modified; + return NULL_TREE; + } + info->modified = modified; + repl = *tp; + } + else + return NULL_TREE; } - else + + if (tp != orig_tp) { - /* You'd think we could skip the extra SSA variable when - wi->val_only=true, but we may have `*var' which will get - replaced into `*var_array[iter]' and will likely be something - not gimple. */ - stmt = gimple_build_assign (repl, unshare_expr (cand->new_decl)); + repl = build_fold_addr_expr (repl); + gimple stmt + = gimple_build_assign (make_ssa_name (TREE_TYPE (repl), NULL), repl); + repl = gimple_assign_lhs (stmt); + gimple_stmt_iterator gsi = gsi_for_stmt (info->stmt); gsi_insert_before (&gsi, stmt, GSI_SAME_STMT); + *orig_tp = repl; } - - if (!useless_type_conversion_p (TREE_TYPE (*tp), TREE_TYPE (repl))) + else if (!useless_type_conversion_p (TREE_TYPE (*tp), TREE_TYPE (repl))) { tree vce = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (*tp), repl); *tp = vce; @@ -11338,8 +11346,6 @@ ipa_simd_modify_stmt_ops (tree *tp, int *walk_subtrees, void *data) *tp = repl; info->modified = true; - wi->is_lhs = false; - wi->val_only = true; return NULL_TREE; } @@ -11358,7 +11364,7 @@ ipa_simd_modify_function_body (struct cgraph_node *node, tree retval_array, tree iter) { basic_block bb; - unsigned int i, j; + unsigned int i, j, l; /* Re-use the adjustments array, but this time use it to replace every function argument use to an offset into the corresponding @@ -11381,6 +11387,46 @@ ipa_simd_modify_function_body (struct cgraph_node *node, j += node->simdclone->simdlen / TYPE_VECTOR_SUBPARTS (vectype) - 1; } + l = adjustments.length (); + for (i = 1; i < num_ssa_names; i++) + { + tree name = ssa_name (i); + if (name + && SSA_NAME_VAR (name) + && TREE_CODE (SSA_NAME_VAR (name)) == PARM_DECL) + { + for (j = 0; j < l; j++) + if (SSA_NAME_VAR (name) == adjustments[j].base + && adjustments[j].new_decl) + { + tree base_var; + if (adjustments[j].new_ssa_base == NULL_TREE) + { + base_var + = copy_var_decl (adjustments[j].base, + DECL_NAME (adjustments[j].base), + TREE_TYPE (adjustments[j].base)); + adjustments[j].new_ssa_base = base_var; + } + else + base_var = adjustments[j].new_ssa_base; + if (SSA_NAME_IS_DEFAULT_DEF (name)) + { + bb = single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)); + gimple_stmt_iterator gsi = gsi_after_labels (bb); + tree new_decl = unshare_expr (adjustments[j].new_decl); + set_ssa_default_def (cfun, adjustments[j].base, NULL_TREE); + SET_SSA_NAME_VAR_OR_IDENTIFIER (name, base_var); + SSA_NAME_IS_DEFAULT_DEF (name) = 0; + gimple stmt = gimple_build_assign (name, new_decl); + gsi_insert_before (&gsi, stmt, GSI_SAME_STMT); + } + else + SET_SSA_NAME_VAR_OR_IDENTIFIER (name, base_var); + } + } + } + struct modify_stmt_info info; info.adjustments = adjustments; diff --git a/gcc-4_9-branch/gcc/testsuite/ChangeLog b/gcc-4_9-branch/gcc/testsuite/ChangeLog index 4c09a1e0525..0c40684238f 100644 --- a/gcc-4_9-branch/gcc/testsuite/ChangeLog +++ b/gcc-4_9-branch/gcc/testsuite/ChangeLog @@ -1,3 +1,68 @@ +2014-04-22 Richard Biener + + Backport from mainline + 2014-04-14 Richard Biener + + PR middle-end/55022 + * gcc.dg/graphite/pr55022.c: New testcase. + +2014-04-22 Richard Biener + + Backport from mainline + 2014-04-17 Richard Biener + + PR middle-end/60849 + * g++.dg/opt/pr60849.C: New testcase. + +2014-04-22 Richard Biener + + Backport from mainline + 2014-04-17 Richard Biener + + PR tree-optimization/60841 + * gcc.dg/vect/pr60841.c: New testcase. + +2014-04-22 Richard Biener + + Backport from mainline + 2014-04-17 Richard Biener + + PR tree-optimization/60836 + * g++.dg/vect/pr60836.cc: New testcase. + +2014-04-22 Richard Biener + + Backport from mainline + 2014-04-14 Richard Biener + Marc Glisse + + PR c/60819 + * gcc.target/i386/vec-may_alias.c: New testcase. + +2014-04-22 Richard Biener + + Backport from mainline + 2014-04-14 Richard Biener + + PR tree-optimization/59817 + PR tree-optimization/60453 + * gfortran.dg/graphite/pr59817.f: New testcase. + * gcc.dg/graphite/pr59817-1.c: Likewise. + * gcc.dg/graphite/pr59817-2.c: Likewise. + +2014-04-22 Jakub Jelinek + + PR tree-optimization/60823 + * c-c++-common/gomp/pr60823-1.c: New test. + * c-c++-common/gomp/pr60823-2.c: New test. + * c-c++-common/gomp/pr60823-3.c: New test. + + Backported from mainline + 2014-04-16 Jakub Jelinek + + PR tree-optimization/60844 + * gcc.dg/pr60844.c: New test. + 2014-04-22 Release Manager * GCC 4.9.0 released. diff --git a/gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-1.c b/gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-1.c new file mode 100644 index 00000000000..5f985724dae --- /dev/null +++ b/gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-1.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/60823 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fopenmp-simd" } */ + +#pragma omp declare simd simdlen(4) notinbranch +int +foo (const double c1, const double c2) +{ + double z1 = c1, z2 = c2; + int res = 100, i; + + for (i = 0; i < 100; i++) + { + res = (z1 * z1 + z2 * z2 > 4.0) ? (i < res ? i : res) : res; + z1 = c1 + z1 * z1 - z2 * z2; + z2 = c2 + 2.0 * z1 * z2; + } + return res; +} diff --git a/gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-2.c b/gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-2.c new file mode 100644 index 00000000000..e0bf570ddca --- /dev/null +++ b/gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-2.c @@ -0,0 +1,43 @@ +/* PR tree-optimization/60823 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fopenmp-simd" } */ + +#pragma omp declare simd simdlen(4) notinbranch +__attribute__((noinline)) int +foo (double c1, double c2) +{ + double z1 = c1, z2 = c2; + int res = 100, i; + + for (i = 0; i < 5; i++) + { + res = (z1 * z1 + z2 * z2 > 4.0) ? (i < res ? i : res) : res; + z1 = c1 + z1 * z1 - z2 * z2; + z2 = c2 + 2.0 * z1 * z2; + c1 += 0.5; + c2 += 0.5; + } + return res; +} + +__attribute__((noinline, noclone)) void +bar (double *x, double *y) +{ + asm volatile ("" : : "rm" (x), "rm" (y) : "memory"); +} + +int +main () +{ + int i; + double c[4] = { 0.0, 1.0, 0.0, 1.0 }; + double d[4] = { 0.0, 1.0, 2.0, 0.0 }; + int e[4]; + bar (c, d); +#pragma omp simd safelen(4) + for (i = 0; i < 4; i++) + e[i] = foo (c[i], d[i]); + if (e[0] != 3 || e[1] != 1 || e[2] != 1 || e[3] != 2) + __builtin_abort (); + return 0; +} diff --git a/gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-3.c b/gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-3.c new file mode 100644 index 00000000000..93e9fbe3a16 --- /dev/null +++ b/gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr60823-3.c @@ -0,0 +1,32 @@ +/* PR tree-optimization/60823 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fopenmp-simd -fno-strict-aliasing" } */ + +void bar (char *, double *); + +#if __SIZEOF_DOUBLE__ >= 4 + +struct S { char c[sizeof (double)]; }; +void baz (struct S, struct S); +union U { struct S s; double d; }; + +#pragma omp declare simd simdlen(4) notinbranch +__attribute__((noinline)) int +foo (double c1, double c2) +{ + double *a = &c1; + char *b = (char *) &c1 + 2; + + b[-2]++; + b[1]--; + *a++; + c2++; + bar ((char *) &c2 + 1, &c2); + c2 *= 3.0; + bar (b, a); + baz (((union U) { .d = c1 }).s, ((union U) { .d = c2 }).s); + baz (*(struct S *)&c1, *(struct S *)&c2); + return c1 + c2 + ((struct S *)&c1)->c[1]; +} + +#endif diff --git a/gcc-4_9-branch/gcc/testsuite/g++.dg/opt/pr60849.C b/gcc-4_9-branch/gcc/testsuite/g++.dg/opt/pr60849.C new file mode 100644 index 00000000000..52d8826b0c8 --- /dev/null +++ b/gcc-4_9-branch/gcc/testsuite/g++.dg/opt/pr60849.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// { dg-options "-O2" } + +int g; + +extern "C" int isnan (); + +void foo(float a) { + int (*xx)(...); + xx = isnan; + if (xx(a)) + g++; +} diff --git a/gcc-4_9-branch/gcc/testsuite/g++.dg/vect/pr60836.cc b/gcc-4_9-branch/gcc/testsuite/g++.dg/vect/pr60836.cc new file mode 100644 index 00000000000..83bb1837531 --- /dev/null +++ b/gcc-4_9-branch/gcc/testsuite/g++.dg/vect/pr60836.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +int a, b; +typedef double (*NormFunc) (const int &); +int & +max (int &p1, int &p2) +{ + if (p1 < p2) + return p2; + return p1; +} + +struct A +{ + int operator () (int p1, int p2) + { + return max (p1, p2); + } +}; +template < class, class > double +norm_ (const int &) +{ + char c, d; + A e; + for (; a; a++) + { + b = e (b, d); + b = e (b, c); + } +} + +void +norm () +{ + static NormFunc f = norm_ < int, A >; + f = 0; +} + +// { dg-final { cleanup-tree-dump "vect" } } diff --git a/gcc-4_9-branch/gcc/testsuite/gcc.dg/graphite/pr55022.c b/gcc-4_9-branch/gcc/testsuite/gcc.dg/graphite/pr55022.c new file mode 100644 index 00000000000..c631c0e23e6 --- /dev/null +++ b/gcc-4_9-branch/gcc/testsuite/gcc.dg/graphite/pr55022.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fgraphite-identity" } */ + +extern void abort (void); + +void __attribute__((noinline,noclone)) +f(int *limit, int minLen, int maxLen) +{ + int i; + + for (i = minLen; i <= maxLen; i++) { + limit[i] = i; + } +} + +int main() +{ + int limit[256], i; + f (limit, 0, 255); + for (i = 0; i < 256; ++i) + { + if (limit[i] != i) + abort (); + __asm__ volatile ("" : : : "memory"); + } + return 0; +} diff --git a/gcc-4_9-branch/gcc/testsuite/gcc.dg/graphite/pr59817-1.c b/gcc-4_9-branch/gcc/testsuite/gcc.dg/graphite/pr59817-1.c new file mode 100644 index 00000000000..175fa16fd71 --- /dev/null +++ b/gcc-4_9-branch/gcc/testsuite/gcc.dg/graphite/pr59817-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -floop-interchange" } */ + +int kd; + +void +n2(void) +{ + static int so; + static short int i5; + int wj; + int *il; + int *nk = &so; + for (wj = 0; wj < 2; ++wj) + *nk = ((i5 += *il) || kd ); +} diff --git a/gcc-4_9-branch/gcc/testsuite/gcc.dg/graphite/pr59817-2.c b/gcc-4_9-branch/gcc/testsuite/gcc.dg/graphite/pr59817-2.c new file mode 100644 index 00000000000..13950076814 --- /dev/null +++ b/gcc-4_9-branch/gcc/testsuite/gcc.dg/graphite/pr59817-2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -floop-interchange" } */ + +void +xl(void) +{ + static int j3; + for (j3 = 0; j3 < 1; ++j3) { + static int f2; + static int w7; + short int b5; + int ok; + f2 = (b5 += ok) ? (w7 = 0): (w7 ? 0 : (f2 = ok)); + } +} diff --git a/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr60844.c b/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr60844.c new file mode 100644 index 00000000000..16ed243d74c --- /dev/null +++ b/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr60844.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/60844 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ +/* { dg-additional-options "-mtune=atom" { target { i?86-*-* x86_64-*-* } } } */ + +void +foo (int *x, int y, int z) +{ + int b, c = x[0], d = x[1]; + for (b = 0; b < 1; b++) + { + int e = (y ? 1 : 0) | (d ? 2 : 0) | (z ? 1 : 0); + e |= (c ? 2 : 0) | ((1 >> b) ? 1 : 0); + x[2 + b] = e; + } +} diff --git a/gcc-4_9-branch/gcc/testsuite/gcc.dg/vect/pr60841.c b/gcc-4_9-branch/gcc/testsuite/gcc.dg/vect/pr60841.c new file mode 100644 index 00000000000..44b5d019169 --- /dev/null +++ b/gcc-4_9-branch/gcc/testsuite/gcc.dg/vect/pr60841.c @@ -0,0 +1,183 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-ffast-math" } */ + +/* This testcase shouldn't consume much memory or produce a 1GB vectorizer + dump file due to SLP tree explosion. */ + +struct S { int f1, f2, f3, f4; } a; +struct T { short f3, f2, f1, f4; }; +int b, c, d, e, f, g; +unsigned long z; + +void +foo (struct T *p, struct T *q, int x, int w) +{ + for (; x; x++) + { + struct S h; + int i; + struct T j; + struct T *r; + h = a; + g = 0; + r = p + 2 * (c + 4) + 1; + j = *r; + r = p; + f = r->f1 - 1; + b = +1.0 + f * f; + i = (r->f2 + j.f2) / 2; + f = r->f3 - 1; + b += 1.0 - i * f * f; + f = r->f4 - 1; + if (b) + b += -1.0 - i * f; + if (b / w) + { + h.f1 += 8.0 * r->f1; + h.f2 += 8.0 * r->f2; + h.f3 += 8.0 * r->f3; + h.f4 += 8.0 * r->f4; + g = 1; + } + r++; + f = r->f1; + i = (r->f2 + j.f2) / 2; + f = r->f3 - 1; + b += 1.0 - i * f * f; + i = (r->f4); + if (b * 65535UL / w) + { + h.f1 += 10.0 * r->f1; + h.f2 += 10.0 * r->f2; + h.f3 += 10.0 * r->f3; + h.f4 += 10.0 * r->f4; + g += 10.0; + } + r++; + f = r->f1; + z = 5UL * i; + f = r->f2; + i = (r->f3 + j.f3) / 2; + b = -i * f * f; + i = (r->f4 + j.f4) / 2; + if (b * 65535UL / 25.0f) + { + h.f1 += 8.0 * r->f1; + h.f2 += 8.0 * r->f2; + h.f3 += 8.0 * r->f3; + h.f4 += 8.0 * r->f4; + g += 8.0; + } + r++; + f = r->f1 - j.f1; + b = 1 * 2.0 * i * f * f; + f = r->f2; + b += 4.0 * f; + i = r->f3 / 2; + f = r->f4 - 1; + if (b * 1) + { + h.f1 += 8.0 * r->f1; + h.f2 += 8.0 * r->f2; + h.f3 += 8.0 * r->f3; + h.f4 += 8.0 * r->f4; + g += 8.0; + } + b = 4.0 * 1 * f; + if (b * 65535UL / 25.0f) + { + h.f1 += 20.0 * r->f1; + h.f2 += 20.0 * r->f2; + h.f3 += 20.0 * r->f3; + h.f4 += 20.0 * r->f4; + g += 20.0; + } + b = 5 * (0.0 - i); + if (b < 0) + { + h.f1 += 8.0 * r->f1; + h.f2 += 8.0 * r->f2; + h.f3 += 8.0 * r->f3; + h.f4 += 8.0 * r->f4; + g += 8.0; + } + r = p + 2 * (c + 4); + i = (r->f1 + j.f1); + b = 1 * 2.0 * i * 1; + f = r->f2 - 1; + i = (r->f3 + j.f3) / 2; + b = 5 * (0.0 - i) * f * f; + i = (r->f4 + j.f4) / 2; + if (b * 65535UL / 25.0f) + { + h.f1 += 10.0 * r->f1; + h.f2 += 10.0 * r->f2; + h.f3 += 10.0 * r->f3; + h.f4 += 10.0 * r->f4; + g += 10.0; + } + r++; + f = r->f1; + b = 5UL * i * f; + i = (r->f2 + j.f2) / 2; + f = r->f3 - 1; + b = 5 * (0.0 - i) * f * f; + f = r->f4 - 1; + if (b * 65535UL / 25.0f) + { + h.f1 += 40.0 * r->f1; + h.f2 += 40.0 * r->f2; + h.f3 += 40.0 * r->f3; + h.f4 += 40.0 * r->f4; + g += 40.0; + } + r++; + i = (r->f1 + j.f1); + b = 5 * i * f; + f = r->f2; + b = 4.0 * f * f; + f = r->f3; + i = (r->f4 + j.f4) / 2; + b = 5 * (0.0 - i) * f * f; + if (b * 25.0f) + { + h.f1 += 8.0 * r->f1; + h.f2 += 8.0 * r->f2; + h.f3 += 8.0 * r->f3; + h.f4 += 8.0 * r->f4; + g += 8.0; + } + r = p + 4 * (c + 4); + i = r->f1 / 2; + b = 5 * (1.0 + i); + i = r->f2 + j.f2; + f = r->f3 - 1; + b = 5 * (0.0 - i) * f * f; + i = (r->f4 + j.f4) / 2; + if (b * 65535UL / 25.0f) + { + h.f1 += 5.0 * r->f1; + h.f2 += 5.0 * r->f2; + h.f3 += 5.0 * r->f3; + h.f4 += 5.0 * r->f4; + g += 5.0; + } + b = 5 * (1.0 + i); + if (b < 0) + { + h.f1 += 5.0 * r->f1; + h.f2 += 5.0 * r->f2; + h.f3 += 5.0 * r->f3; + h.f4 += 5.0 * r->f4; + g += 5.0; + } + q->f1 = (h.f1 + g / 2 - 1) / g; + q->f2 = (h.f2 + g / 2 - 1) / g; + q->f3 = (h.f3 + g / 2 - 1) / g; + q->f4 = (h.f4 + g / 2 - 1) / g; + p++; + q++; + } +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc-4_9-branch/gcc/testsuite/gcc.target/i386/vec-may_alias.c b/gcc-4_9-branch/gcc/testsuite/gcc.target/i386/vec-may_alias.c new file mode 100644 index 00000000000..e970497454f --- /dev/null +++ b/gcc-4_9-branch/gcc/testsuite/gcc.target/i386/vec-may_alias.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -w -Wno-abi" } */ + +typedef int v2si __attribute__ ((vector_size (8))); +typedef short v4hi __attribute__ ((vector_size (8))); +typedef short v4hia __attribute__ ((vector_size (8), may_alias)); + +__attribute__ ((noinline, noclone)) +int f (v2si A, int N) +{ return ((v4hia)A)[N]; } + +__attribute__ ((noinline, noclone)) +int g (v2si A, int N) +{ return ((v4hi)A)[N]; } + +int main() +{ + v2si x = { 0, 0 }, y = { 1, 1 }; + if (f (x, 0) || f (x, 1) || f (x, 2) || f (x, 3)) + __builtin_abort (); + if (g (y, 0) != 1 || g (y, 1) || g (y, 2) != 1 || g (y, 3)) + __builtin_abort (); + return 0; +} + diff --git a/gcc-4_9-branch/gcc/testsuite/gfortran.dg/graphite/pr59817.f b/gcc-4_9-branch/gcc/testsuite/gfortran.dg/graphite/pr59817.f new file mode 100644 index 00000000000..a9ee8f19dd7 --- /dev/null +++ b/gcc-4_9-branch/gcc/testsuite/gfortran.dg/graphite/pr59817.f @@ -0,0 +1,14 @@ +! { dg-do compile } +! { dg-options "-O2 -floop-interchange" } + SUBROUTINE PREPD(ICAST,ICAS,ICASX,ICAS1,ICAS2,NDET,NM,III,IMP, + * CASMIN) + LOGICAL CASMIN + DIMENSION ICAST(NDET,NM),IMP(NM) + IF(CASMIN) THEN + DO K=1,NDET + DO L=1,NM + IF(L.EQ.K-1) ICAST(K,L) = 1 + END DO + END DO + END IF + END SUBROUTINE diff --git a/gcc-4_9-branch/gcc/tree-dfa.c b/gcc-4_9-branch/gcc/tree-dfa.c index fcf8d80fda4..a1f27587487 100644 --- a/gcc-4_9-branch/gcc/tree-dfa.c +++ b/gcc-4_9-branch/gcc/tree-dfa.c @@ -343,7 +343,7 @@ set_ssa_default_def (struct function *fn, tree var, tree def) { loc = htab_find_slot_with_hash (DEFAULT_DEFS (fn), &in, DECL_UID (var), NO_INSERT); - if (*loc) + if (loc) { SSA_NAME_IS_DEFAULT_DEF (*(tree *)loc) = false; htab_clear_slot (DEFAULT_DEFS (fn), loc); diff --git a/gcc-4_9-branch/gcc/tree-ssa-propagate.c b/gcc-4_9-branch/gcc/tree-ssa-propagate.c index 840d7e76272..172b6386e16 100644 --- a/gcc-4_9-branch/gcc/tree-ssa-propagate.c +++ b/gcc-4_9-branch/gcc/tree-ssa-propagate.c @@ -571,8 +571,18 @@ valid_gimple_rhs_p (tree expr) /* All constants are ok. */ break; - case tcc_binary: case tcc_comparison: + /* GENERIC allows comparisons with non-boolean types, reject + those for GIMPLE. Let vector-typed comparisons pass - rules + for GENERIC and GIMPLE are the same here. */ + if (!(INTEGRAL_TYPE_P (TREE_TYPE (expr)) + && (TREE_CODE (TREE_TYPE (expr)) == BOOLEAN_TYPE + || TYPE_PRECISION (TREE_TYPE (expr)) == 1)) + && TREE_CODE (TREE_TYPE (expr)) != VECTOR_TYPE) + return false; + + /* Fallthru. */ + case tcc_binary: if (!is_gimple_val (TREE_OPERAND (expr, 0)) || !is_gimple_val (TREE_OPERAND (expr, 1))) return false; diff --git a/gcc-4_9-branch/gcc/tree-ssa-reassoc.c b/gcc-4_9-branch/gcc/tree-ssa-reassoc.c index e9e29e550f7..fce2a6e20f6 100644 --- a/gcc-4_9-branch/gcc/tree-ssa-reassoc.c +++ b/gcc-4_9-branch/gcc/tree-ssa-reassoc.c @@ -221,6 +221,35 @@ static struct pointer_map_t *operand_rank; static long get_rank (tree); static bool reassoc_stmt_dominates_stmt_p (gimple, gimple); +/* Wrapper around gsi_remove, which adjusts gimple_uid of debug stmts + possibly added by gsi_remove. */ + +bool +reassoc_remove_stmt (gimple_stmt_iterator *gsi) +{ + gimple stmt = gsi_stmt (*gsi); + + if (!MAY_HAVE_DEBUG_STMTS || gimple_code (stmt) == GIMPLE_PHI) + return gsi_remove (gsi, true); + + gimple_stmt_iterator prev = *gsi; + gsi_prev (&prev); + unsigned uid = gimple_uid (stmt); + basic_block bb = gimple_bb (stmt); + bool ret = gsi_remove (gsi, true); + if (!gsi_end_p (prev)) + gsi_next (&prev); + else + prev = gsi_start_bb (bb); + gimple end_stmt = gsi_stmt (*gsi); + while ((stmt = gsi_stmt (prev)) != end_stmt) + { + gcc_assert (stmt && is_gimple_debug (stmt) && gimple_uid (stmt) == 0); + gimple_set_uid (stmt, uid); + gsi_next (&prev); + } + return ret; +} /* Bias amount for loop-carried phis. We want this to be larger than the depth of any reassociation tree we can see, but not larger than @@ -1123,7 +1152,7 @@ propagate_op_to_single_use (tree op, gimple stmt, tree *def) update_stmt (use_stmt); gsi = gsi_for_stmt (stmt); unlink_stmt_vdef (stmt); - gsi_remove (&gsi, true); + reassoc_remove_stmt (&gsi); release_defs (stmt); } @@ -3072,7 +3101,7 @@ remove_visited_stmt_chain (tree var) { var = gimple_assign_rhs1 (stmt); gsi = gsi_for_stmt (stmt); - gsi_remove (&gsi, true); + reassoc_remove_stmt (&gsi); release_defs (stmt); } else @@ -3494,7 +3523,7 @@ linearize_expr (gimple stmt) update_stmt (stmt); gsi = gsi_for_stmt (oldbinrhs); - gsi_remove (&gsi, true); + reassoc_remove_stmt (&gsi); release_defs (oldbinrhs); gimple_set_visited (stmt, true); @@ -3896,7 +3925,7 @@ repropagate_negates (void) gimple_assign_set_rhs_with_ops (&gsi2, NEGATE_EXPR, x, NULL); user = gsi_stmt (gsi2); update_stmt (user); - gsi_remove (&gsi, true); + reassoc_remove_stmt (&gsi); release_defs (feed); plus_negates.safe_push (gimple_assign_lhs (user)); } @@ -4413,7 +4442,7 @@ reassociate_bb (basic_block bb) reassociations. */ if (has_zero_uses (gimple_get_lhs (stmt))) { - gsi_remove (&gsi, true); + reassoc_remove_stmt (&gsi); release_defs (stmt); /* We might end up removing the last stmt above which places the iterator to the end of the sequence. diff --git a/gcc-4_9-branch/gcc/tree-vect-data-refs.c b/gcc-4_9-branch/gcc/tree-vect-data-refs.c index fbc35a3fe3c..274cdbdcf80 100644 --- a/gcc-4_9-branch/gcc/tree-vect-data-refs.c +++ b/gcc-4_9-branch/gcc/tree-vect-data-refs.c @@ -3172,7 +3172,7 @@ vect_check_gather (gimple stmt, loop_vec_info loop_vinfo, tree *basep, bool vect_analyze_data_refs (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, - int *min_vf) + int *min_vf, unsigned *n_stmts) { struct loop *loop = NULL; basic_block bb = NULL; @@ -3207,6 +3207,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, for (gsi = gsi_start_bb (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); + if (is_gimple_debug (stmt)) + continue; + ++*n_stmts; if (!find_data_references_in_stmt (loop, stmt, &datarefs)) { if (is_gimple_call (stmt) && loop->safelen) @@ -3260,6 +3263,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); + if (is_gimple_debug (stmt)) + continue; + ++*n_stmts; if (!find_data_references_in_stmt (NULL, stmt, &BB_VINFO_DATAREFS (bb_vinfo))) { diff --git a/gcc-4_9-branch/gcc/tree-vect-loop.c b/gcc-4_9-branch/gcc/tree-vect-loop.c index 1c78e114fe1..4204907a133 100644 --- a/gcc-4_9-branch/gcc/tree-vect-loop.c +++ b/gcc-4_9-branch/gcc/tree-vect-loop.c @@ -1629,6 +1629,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo) int max_vf = MAX_VECTORIZATION_FACTOR; int min_vf = 2; unsigned int th; + unsigned int n_stmts = 0; /* Find all data references in the loop (which correspond to vdefs/vuses) and analyze their evolution in the loop. Also adjust the minimal @@ -1637,7 +1638,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo) FORNOW: Handle only simple, array references, which alignment can be forced, and aligned pointer-references. */ - ok = vect_analyze_data_refs (loop_vinfo, NULL, &min_vf); + ok = vect_analyze_data_refs (loop_vinfo, NULL, &min_vf, &n_stmts); if (!ok) { if (dump_enabled_p ()) @@ -1747,7 +1748,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo) } /* Check the SLP opportunities in the loop, analyze and build SLP trees. */ - ok = vect_analyze_slp (loop_vinfo, NULL); + ok = vect_analyze_slp (loop_vinfo, NULL, n_stmts); if (ok) { /* Decide which possible SLP instances to SLP. */ @@ -3951,8 +3952,12 @@ vect_create_epilog_for_reduction (vec vect_defs, gimple stmt, /* Set phi nodes arguments. */ FOR_EACH_VEC_ELT (reduction_phis, i, phi) { - tree vec_init_def = vec_initial_defs[i]; - tree def = vect_defs[i]; + tree vec_init_def, def; + gimple_seq stmts; + vec_init_def = force_gimple_operand (vec_initial_defs[i], &stmts, + true, NULL_TREE); + gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts); + def = vect_defs[i]; for (j = 0; j < ncopies; j++) { /* Set the loop-entry arg of the reduction-phi. */ diff --git a/gcc-4_9-branch/gcc/tree-vect-slp.c b/gcc-4_9-branch/gcc/tree-vect-slp.c index 65f8b022e92..0ab267f7d8e 100644 --- a/gcc-4_9-branch/gcc/tree-vect-slp.c +++ b/gcc-4_9-branch/gcc/tree-vect-slp.c @@ -849,9 +849,10 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, unsigned int *max_nunits, vec *loads, unsigned int vectorization_factor, - bool *matches, unsigned *npermutes) + bool *matches, unsigned *npermutes, unsigned *tree_size, + unsigned max_tree_size) { - unsigned nops, i, this_npermutes = 0; + unsigned nops, i, this_npermutes = 0, this_tree_size = 0; gimple stmt; if (!matches) @@ -911,6 +912,12 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, if (oprnd_info->first_dt != vect_internal_def) continue; + if (++this_tree_size > max_tree_size) + { + vect_free_oprnd_info (oprnds_info); + return false; + } + child = vect_create_new_slp_node (oprnd_info->def_stmts); if (!child) { @@ -921,7 +928,8 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, bool *matches = XALLOCAVEC (bool, group_size); if (vect_build_slp_tree (loop_vinfo, bb_vinfo, &child, group_size, max_nunits, loads, - vectorization_factor, matches, npermutes)) + vectorization_factor, matches, + npermutes, &this_tree_size, max_tree_size)) { oprnd_info->def_stmts = vNULL; SLP_TREE_CHILDREN (*node).quick_push (child); @@ -961,7 +969,8 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, if (vect_build_slp_tree (loop_vinfo, bb_vinfo, &child, group_size, max_nunits, loads, vectorization_factor, - matches, npermutes)) + matches, npermutes, &this_tree_size, + max_tree_size)) { oprnd_info->def_stmts = vNULL; SLP_TREE_CHILDREN (*node).quick_push (child); @@ -977,6 +986,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, return false; } + if (tree_size) + *tree_size += this_tree_size; + vect_free_oprnd_info (oprnds_info); return true; } @@ -1436,7 +1448,7 @@ vect_analyze_slp_cost (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, static bool vect_analyze_slp_instance (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, - gimple stmt) + gimple stmt, unsigned max_tree_size) { slp_instance new_instance; slp_tree node; @@ -1536,7 +1548,8 @@ vect_analyze_slp_instance (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, /* Build the tree for the SLP instance. */ if (vect_build_slp_tree (loop_vinfo, bb_vinfo, &node, group_size, &max_nunits, &loads, - vectorization_factor, NULL, NULL)) + vectorization_factor, NULL, NULL, NULL, + max_tree_size)) { /* Calculate the unrolling factor based on the smallest type. */ if (max_nunits > nunits) @@ -1641,7 +1654,8 @@ vect_analyze_slp_instance (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, trees of packed scalar stmts if SLP is possible. */ bool -vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo) +vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, + unsigned max_tree_size) { unsigned int i; vec grouped_stores; @@ -1664,7 +1678,8 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo) /* Find SLP sequences starting from groups of grouped stores. */ FOR_EACH_VEC_ELT (grouped_stores, i, first_element) - if (vect_analyze_slp_instance (loop_vinfo, bb_vinfo, first_element)) + if (vect_analyze_slp_instance (loop_vinfo, bb_vinfo, first_element, + max_tree_size)) ok = true; if (bb_vinfo && !ok) @@ -1681,7 +1696,8 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo) { /* Find SLP sequences starting from reduction chains. */ FOR_EACH_VEC_ELT (reduc_chains, i, first_element) - if (vect_analyze_slp_instance (loop_vinfo, bb_vinfo, first_element)) + if (vect_analyze_slp_instance (loop_vinfo, bb_vinfo, first_element, + max_tree_size)) ok = true; else return false; @@ -1693,7 +1709,8 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo) /* Find SLP sequences starting from groups of reductions. */ if (loop_vinfo && LOOP_VINFO_REDUCTIONS (loop_vinfo).length () > 1 - && vect_analyze_slp_instance (loop_vinfo, bb_vinfo, reductions[0])) + && vect_analyze_slp_instance (loop_vinfo, bb_vinfo, reductions[0], + max_tree_size)) ok = true; return true; @@ -2071,12 +2088,13 @@ vect_slp_analyze_bb_1 (basic_block bb) slp_instance instance; int i; int min_vf = 2; + unsigned n_stmts = 0; bb_vinfo = new_bb_vec_info (bb); if (!bb_vinfo) return NULL; - if (!vect_analyze_data_refs (NULL, bb_vinfo, &min_vf)) + if (!vect_analyze_data_refs (NULL, bb_vinfo, &min_vf, &n_stmts)) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, @@ -2124,7 +2142,7 @@ vect_slp_analyze_bb_1 (basic_block bb) /* Check the SLP opportunities in the basic block, analyze and build SLP trees. */ - if (!vect_analyze_slp (NULL, bb_vinfo)) + if (!vect_analyze_slp (NULL, bb_vinfo, n_stmts)) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, diff --git a/gcc-4_9-branch/gcc/tree-vectorizer.h b/gcc-4_9-branch/gcc/tree-vectorizer.h index f2087e22383..fa2989d7286 100644 --- a/gcc-4_9-branch/gcc/tree-vectorizer.h +++ b/gcc-4_9-branch/gcc/tree-vectorizer.h @@ -1057,7 +1057,8 @@ extern bool vect_analyze_data_ref_accesses (loop_vec_info, bb_vec_info); extern bool vect_prune_runtime_alias_test_list (loop_vec_info); extern tree vect_check_gather (gimple, loop_vec_info, tree *, tree *, int *); -extern bool vect_analyze_data_refs (loop_vec_info, bb_vec_info, int *); +extern bool vect_analyze_data_refs (loop_vec_info, bb_vec_info, int *, + unsigned *); extern tree vect_create_data_ref_ptr (gimple, tree, struct loop *, tree, tree *, gimple_stmt_iterator *, gimple *, bool, bool *); @@ -1107,7 +1108,7 @@ extern bool vect_transform_slp_perm_load (slp_tree, vec , slp_instance, bool); extern bool vect_schedule_slp (loop_vec_info, bb_vec_info); extern void vect_update_slp_costs_according_to_vf (loop_vec_info); -extern bool vect_analyze_slp (loop_vec_info, bb_vec_info); +extern bool vect_analyze_slp (loop_vec_info, bb_vec_info, unsigned); extern bool vect_make_slp_decision (loop_vec_info); extern void vect_detect_hybrid_slp (loop_vec_info); extern void vect_get_slp_defs (vec , slp_tree, -- 2.11.4.GIT