Commit 4f1f33aa by Jakub Jelinek Committed by Jakub Jelinek

re PR tree-optimization/34371 (verify_stmts failed (incorrect sharing of tree nodes))

	PR tree-optimization/34371
	* tree-vectorizer.h (struct _loop_vec_info): Add num_iters_unchanged
	field.
	(LOOP_VINFO_NITERS_UNCHANGED): Define to num_iters_unchanged field.
	* tree-vectorizer.c (set_prologue_iterations,
	slpeel_tree_peel_loop_to_edge): Call unshare_expr on
	LOOP_VINFO_NITERS_UNCHANGED before using it.

	* gcc.c-torture/compile/20071207-1.c: New test.

From-SVN: r130755
parent 0197270c
2007-12-10 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/34371
* tree-vectorizer.h (struct _loop_vec_info): Add num_iters_unchanged
field.
(LOOP_VINFO_NITERS_UNCHANGED): Define to num_iters_unchanged field.
* tree-vectorizer.c (set_prologue_iterations,
slpeel_tree_peel_loop_to_edge): Call unshare_expr on
LOOP_VINFO_NITERS_UNCHANGED before using it.
2007-12-10 Eric Botcazou <ebotcazou@libertysurf.fr> 2007-12-10 Eric Botcazou <ebotcazou@libertysurf.fr>
PR target/34403 PR target/34403
2007-12-10 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/34371
* gcc.c-torture/compile/20071207-1.c: New test.
2007-12-10 Simon Martin <simartin@users.sourceforge.net> 2007-12-10 Simon Martin <simartin@users.sourceforge.net>
PR c++/34059 PR c++/34059
/* PR tree-optimization/34371 */
/* Testcase by Martin Michlmayr <tbm@cyrius.com> */
void centerln (int width, int ch, char *s)
{
unsigned int sidebar;
int i;
char linet1[1000];
char linet2[100];
sidebar = (width - __builtin_strlen (s)) / 2;
for (i = 0; i < sidebar; i++)
linet2[i] = ch;
__builtin_strcpy (linet1, linet2);
}
...@@ -1037,7 +1037,7 @@ set_prologue_iterations (basic_block bb_before_first_loop, ...@@ -1037,7 +1037,7 @@ set_prologue_iterations (basic_block bb_before_first_loop,
tree gimplify_stmt_list; tree gimplify_stmt_list;
tree cost_pre_condition = NULL_TREE; tree cost_pre_condition = NULL_TREE;
tree scalar_loop_iters = tree scalar_loop_iters =
LOOP_VINFO_NITERS_UNCHANGED (loop_vec_info_for_loop (loop)); unshare_expr (LOOP_VINFO_NITERS_UNCHANGED (loop_vec_info_for_loop (loop)));
e = single_pred_edge (bb_before_first_loop); e = single_pred_edge (bb_before_first_loop);
cond_bb = split_edge(e); cond_bb = split_edge(e);
...@@ -1154,8 +1154,6 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop, ...@@ -1154,8 +1154,6 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop,
edge exit_e = single_exit (loop); edge exit_e = single_exit (loop);
LOC loop_loc; LOC loop_loc;
tree cost_pre_condition = NULL_TREE; tree cost_pre_condition = NULL_TREE;
tree scalar_loop_iters =
LOOP_VINFO_NITERS_UNCHANGED (loop_vec_info_for_loop (loop));
if (!slpeel_can_duplicate_loop_p (loop, e)) if (!slpeel_can_duplicate_loop_p (loop, e))
return NULL; return NULL;
...@@ -1307,10 +1305,13 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop, ...@@ -1307,10 +1305,13 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop,
build_int_cst (TREE_TYPE (first_niters), 0)); build_int_cst (TREE_TYPE (first_niters), 0));
if (check_profitability) if (check_profitability)
{ {
cost_pre_condition = tree scalar_loop_iters
= unshare_expr (LOOP_VINFO_NITERS_UNCHANGED
(loop_vec_info_for_loop (loop)));
cost_pre_condition =
build2 (LE_EXPR, boolean_type_node, scalar_loop_iters, build2 (LE_EXPR, boolean_type_node, scalar_loop_iters,
build_int_cst (TREE_TYPE (scalar_loop_iters), th)); build_int_cst (TREE_TYPE (scalar_loop_iters), th));
pre_condition = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, pre_condition = fold_build2 (TRUTH_OR_EXPR, boolean_type_node,
cost_pre_condition, pre_condition); cost_pre_condition, pre_condition);
} }
......
...@@ -164,6 +164,7 @@ typedef struct _loop_vec_info { ...@@ -164,6 +164,7 @@ typedef struct _loop_vec_info {
/* Number of iterations. */ /* Number of iterations. */
tree num_iters; tree num_iters;
tree num_iters_unchanged;
/* Minimum number of iterations below which vectorization is expected to /* Minimum number of iterations below which vectorization is expected to
not be profitable (as estimated by the cost model). not be profitable (as estimated by the cost model).
...@@ -230,7 +231,7 @@ typedef struct _loop_vec_info { ...@@ -230,7 +231,7 @@ typedef struct _loop_vec_info {
#define LOOP_VINFO_NITERS(L) (L)->num_iters #define LOOP_VINFO_NITERS(L) (L)->num_iters
/* Since LOOP_VINFO_NITERS can change after prologue peeling /* Since LOOP_VINFO_NITERS can change after prologue peeling
retain total unchanged scalar loop iterations for cost model. */ retain total unchanged scalar loop iterations for cost model. */
#define LOOP_VINFO_NITERS_UNCHANGED(L) (L)->num_iters #define LOOP_VINFO_NITERS_UNCHANGED(L) (L)->num_iters_unchanged
#define LOOP_VINFO_COST_MODEL_MIN_ITERS(L) (L)->min_profitable_iters #define LOOP_VINFO_COST_MODEL_MIN_ITERS(L) (L)->min_profitable_iters
#define LOOP_VINFO_VECTORIZABLE_P(L) (L)->vectorizable #define LOOP_VINFO_VECTORIZABLE_P(L) (L)->vectorizable
#define LOOP_VINFO_VECT_FACTOR(L) (L)->vectorization_factor #define LOOP_VINFO_VECT_FACTOR(L) (L)->vectorization_factor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment