Commit 0ac168a1 by Richard Guenther Committed by Richard Biener

re PR tree-optimization/52678 (internal compiler error: in…

re PR tree-optimization/52678 (internal compiler error: in vect_update_ivs_after_vectorizer, at tree-vect-loop-manip.c:1842)

2012-03-23  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/52678
	* tree-vectorizer.h (struct _stmt_vec_info): Add
	loop_phi_evolution_part member.
	(STMT_VINFO_LOOP_PHI_EVOLUTION_PART): New define.
	* tree-vect-loop.c (vect_analyze_scalar_cycles_1): Initialize
	STMT_VINFO_LOOP_PHI_EVOLUTION_PART.
	* tree-vect-loop-manip.c (vect_update_ivs_after_vectorizer):
	Use the cached evolution part and the PHI nodes value from
	the loop preheader edge instead of re-analyzing the evolution.

	* gfortran.dg/pr52678.f: New testcase.

From-SVN: r185734
parent 6e349de5
2012-03-23 Richard Guenther <rguenther@suse.de>
PR tree-optimization/52678
* tree-vectorizer.h (struct _stmt_vec_info): Add
loop_phi_evolution_part member.
(STMT_VINFO_LOOP_PHI_EVOLUTION_PART): New define.
* tree-vect-loop.c (vect_analyze_scalar_cycles_1): Initialize
STMT_VINFO_LOOP_PHI_EVOLUTION_PART.
* tree-vect-loop-manip.c (vect_update_ivs_after_vectorizer):
Use the cached evolution part and the PHI nodes value from
the loop preheader edge instead of re-analyzing the evolution.
2012-03-22 Maxim Kuvyrkov <maxim@codesourcery.com> 2012-03-22 Maxim Kuvyrkov <maxim@codesourcery.com>
* config/mips/mips-tables.opt: Update. * config/mips/mips-tables.opt: Update.
......
2012-03-23 Richard Guenther <rguenther@suse.de> 2012-03-23 Richard Guenther <rguenther@suse.de>
PR tree-optimization/52678
* gfortran.dg/pr52678.f: New testcase.
2012-03-23 Richard Guenther <rguenther@suse.de>
PR tree-optimization/52638 PR tree-optimization/52638
* g++.dg/torture/pr52638.C: New testcase. * g++.dg/torture/pr52638.C: New testcase.
......
! { dg-do compile }
! { dg-options "-O -ftree-vectorize" }
SUBROUTINE OpenAD_set_ref_state(DRF, RHOFACF, RHOFACC)
real(8) DRF(1 : 15)
real(8) RHOFACF(1 : 16)
real(8) RHOFACC(1 : 15)
integer, dimension(:), allocatable :: oad_it
integer :: oad_it_ptr
INTEGER(8) OpenAD_Symbol_188
INTEGER(4) K
OpenAD_Symbol_188 = 0
DO K = 2, 15, 1
RHOFACF(INT(K)) = ((RHOFACC(K) * DRF(K + (-1)) + RHOFACC(K +
+ (-1)) * DRF(K)) /(DRF(K) + DRF(K + (-1))))
OpenAD_Symbol_188 = (INT(OpenAD_Symbol_188) + INT(1))
END DO
oad_it(oad_it_ptr) = OpenAD_Symbol_188
end subroutine OpenAD_set_ref_state
...@@ -1797,13 +1797,12 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters, ...@@ -1797,13 +1797,12 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
!gsi_end_p (gsi) && !gsi_end_p (gsi1); !gsi_end_p (gsi) && !gsi_end_p (gsi1);
gsi_next (&gsi), gsi_next (&gsi1)) gsi_next (&gsi), gsi_next (&gsi1))
{ {
tree access_fn = NULL;
tree evolution_part;
tree init_expr; tree init_expr;
tree step_expr, off; tree step_expr, off;
tree type; tree type;
tree var, ni, ni_name; tree var, ni, ni_name;
gimple_stmt_iterator last_gsi; gimple_stmt_iterator last_gsi;
stmt_vec_info stmt_info;
phi = gsi_stmt (gsi); phi = gsi_stmt (gsi);
phi1 = gsi_stmt (gsi1); phi1 = gsi_stmt (gsi1);
...@@ -1822,45 +1821,34 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters, ...@@ -1822,45 +1821,34 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
} }
/* Skip reduction phis. */ /* Skip reduction phis. */
if (STMT_VINFO_DEF_TYPE (vinfo_for_stmt (phi)) == vect_reduction_def) stmt_info = vinfo_for_stmt (phi);
if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def)
{ {
if (vect_print_dump_info (REPORT_DETAILS)) if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "reduc phi. skip."); fprintf (vect_dump, "reduc phi. skip.");
continue; continue;
} }
access_fn = analyze_scalar_evolution (loop, PHI_RESULT (phi)); type = TREE_TYPE (gimple_phi_result (phi));
gcc_assert (access_fn); step_expr = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_info);
/* We can end up with an access_fn like step_expr = unshare_expr (step_expr);
(short int) {(short unsigned int) i_49, +, 1}_1
for further analysis we need to strip the outer cast but we
need to preserve the original type. */
type = TREE_TYPE (access_fn);
STRIP_NOPS (access_fn);
evolution_part =
unshare_expr (evolution_part_in_loop_num (access_fn, loop->num));
gcc_assert (evolution_part != NULL_TREE);
/* FORNOW: We do not support IVs whose evolution function is a polynomial /* FORNOW: We do not support IVs whose evolution function is a polynomial
of degree >= 2 or exponential. */ of degree >= 2 or exponential. */
gcc_assert (!tree_is_chrec (evolution_part)); gcc_assert (!tree_is_chrec (step_expr));
step_expr = evolution_part; init_expr = PHI_ARG_DEF_FROM_EDGE (phi, loop_preheader_edge (loop));
init_expr = unshare_expr (initial_condition_in_loop_num (access_fn,
loop->num));
init_expr = fold_convert (type, init_expr);
off = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr), off = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr),
fold_convert (TREE_TYPE (step_expr), niters), fold_convert (TREE_TYPE (step_expr), niters),
step_expr); step_expr);
if (POINTER_TYPE_P (TREE_TYPE (init_expr))) if (POINTER_TYPE_P (type))
ni = fold_build_pointer_plus (init_expr, off); ni = fold_build_pointer_plus (init_expr, off);
else else
ni = fold_build2 (PLUS_EXPR, TREE_TYPE (init_expr), ni = fold_build2 (PLUS_EXPR, type,
init_expr, init_expr, fold_convert (type, off));
fold_convert (TREE_TYPE (init_expr), off));
var = create_tmp_var (TREE_TYPE (init_expr), "tmp"); var = create_tmp_var (type, "tmp");
add_referenced_var (var); add_referenced_var (var);
last_gsi = gsi_last_bb (exit_bb); last_gsi = gsi_last_bb (exit_bb);
......
...@@ -579,6 +579,10 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop) ...@@ -579,6 +579,10 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_vinfo, struct loop *loop)
continue; continue;
} }
STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo)
= evolution_part_in_loop_num (access_fn, loop->num);
gcc_assert (STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo) != NULL_TREE);
if (vect_print_dump_info (REPORT_DETAILS)) if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "Detected induction."); fprintf (vect_dump, "Detected induction.");
STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_induction_def; STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_induction_def;
......
...@@ -476,6 +476,13 @@ typedef struct _stmt_vec_info { ...@@ -476,6 +476,13 @@ typedef struct _stmt_vec_info {
tree dr_step; tree dr_step;
tree dr_aligned_to; tree dr_aligned_to;
/* For loop PHI nodes, the evolution part of it. This makes sure
this information is still available in vect_update_ivs_after_vectorizer
where we may not be able to re-analyze the PHI nodes evolution as
peeling for the prologue loop can make it unanalyzable. The evolution
part is still correct though. */
tree loop_phi_evolution_part;
/* Used for various bookkeeping purposes, generally holding a pointer to /* Used for various bookkeeping purposes, generally holding a pointer to
some other stmt S that is in some way "related" to this stmt. some other stmt S that is in some way "related" to this stmt.
Current use of this field is: Current use of this field is:
...@@ -572,6 +579,7 @@ typedef struct _stmt_vec_info { ...@@ -572,6 +579,7 @@ typedef struct _stmt_vec_info {
#define STMT_VINFO_GROUP_SAME_DR_STMT(S) (S)->same_dr_stmt #define STMT_VINFO_GROUP_SAME_DR_STMT(S) (S)->same_dr_stmt
#define STMT_VINFO_GROUP_READ_WRITE_DEPENDENCE(S) (S)->read_write_dep #define STMT_VINFO_GROUP_READ_WRITE_DEPENDENCE(S) (S)->read_write_dep
#define STMT_VINFO_STRIDED_ACCESS(S) ((S)->first_element != NULL && (S)->data_ref_info) #define STMT_VINFO_STRIDED_ACCESS(S) ((S)->first_element != NULL && (S)->data_ref_info)
#define STMT_VINFO_LOOP_PHI_EVOLUTION_PART(S) (S)->loop_phi_evolution_part
#define GROUP_FIRST_ELEMENT(S) (S)->first_element #define GROUP_FIRST_ELEMENT(S) (S)->first_element
#define GROUP_NEXT_ELEMENT(S) (S)->next_element #define GROUP_NEXT_ELEMENT(S) (S)->next_element
......
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