Commit a0dd1440 by Sebastian Pop Committed by Sebastian Pop

graphite-dependences.c (reduction_ddr): New.

2009-10-05  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-dependences.c (reduction_ddr): New.
	(graphite_legal_transform_bb): Call reduction_ddr.
	* graphite-poly.c (new_poly_bb): Pass a new bool parameter.
	Initialize PBB_IS_REDUCTION.
	* graphite-poly.h (struct poly_bb): New bool field is_reduction.
	(PBB_IS_REDUCTION): New.
	(new_poly_bb): Update declaration.
	* graphite-scop-detection.h (build_scop_bbs): Removed.
	(nb_reductions_in_loop): Removed.
	* graphite-sese-to-poly.c (try_generate_gimple_bb): Pass a sbitmap
	parameter for reductions.
	(try_generate_gimple_bb): Update call to new_poly_bb.
	(build_scop_bbs_1): Same.
	(build_scop_bbs): Same.
	(gsi_for_phi_node): New.
	(scalar_close_phi_node_p): Remove gcc_assert.
	(split_reduction_stmt): New.
	(is_reduction_operation_p): New.
	(phi_contains_arg): New.
	(follow_ssa_with_commutative_ops): New.
	(detect_commutative_reduction_arg): New.
	(detect_commutative_reduction_assign): New.
	(follow_inital_value_to_phi): New.
	(edge_initial_value_for_loop_phi): New.
	(initial_value_for_loop_phi): New.
	(detect_commutative_reduction): New.
	(translate_scalar_reduction_to_array_for_stmt): New.
	(insert_copyout): New.
	(insert_copyin): New.
	(translate_scalar_reduction_to_array): New.
	(rewrite_commutative_reductions_out_of_ssa_close_phi): New.
	(rewrite_commutative_reductions_out_of_ssa_loop): New.
	(rewrite_commutative_reductions_out_of_ssa): New.
	(build_poly_scop): Call rewrite_commutative_reductions_out_of_ssa.
	* sese.h (split_region_for_bb): New.

	* gcc.dg/graphite/graphite.exp (DEFAULT_CFLAGS_GRAPHITE_BLOCK): Add -ffast-math.
	* gcc.dg/graphite/interchange-1.c: Fix format.
	* gcc.dg/graphite/interchange-10.c: New.

From-SVN: r154561
parent db7e9485
2009-10-05 Sebastian Pop <sebastian.pop@amd.com>
* graphite-dependences.c (reduction_ddr): New.
(graphite_legal_transform_bb): Call reduction_ddr.
* graphite-poly.c (new_poly_bb): Pass a new bool parameter.
Initialize PBB_IS_REDUCTION.
* graphite-poly.h (struct poly_bb): New bool field is_reduction.
(PBB_IS_REDUCTION): New.
(new_poly_bb): Update declaration.
* graphite-scop-detection.h (build_scop_bbs): Removed.
(nb_reductions_in_loop): Removed.
* graphite-sese-to-poly.c (try_generate_gimple_bb): Pass a sbitmap
parameter for reductions.
(try_generate_gimple_bb): Update call to new_poly_bb.
(build_scop_bbs_1): Same.
(build_scop_bbs): Same.
(gsi_for_phi_node): New.
(scalar_close_phi_node_p): Remove gcc_assert.
(split_reduction_stmt): New.
(is_reduction_operation_p): New.
(phi_contains_arg): New.
(follow_ssa_with_commutative_ops): New.
(detect_commutative_reduction_arg): New.
(detect_commutative_reduction_assign): New.
(follow_inital_value_to_phi): New.
(edge_initial_value_for_loop_phi): New.
(initial_value_for_loop_phi): New.
(detect_commutative_reduction): New.
(translate_scalar_reduction_to_array_for_stmt): New.
(insert_copyout): New.
(insert_copyin): New.
(translate_scalar_reduction_to_array): New.
(rewrite_commutative_reductions_out_of_ssa_close_phi): New.
(rewrite_commutative_reductions_out_of_ssa_loop): New.
(rewrite_commutative_reductions_out_of_ssa): New.
(build_poly_scop): Call rewrite_commutative_reductions_out_of_ssa.
* sese.h (split_region_for_bb): New.
* gcc.dg/graphite/graphite.exp (DEFAULT_CFLAGS_GRAPHITE_BLOCK): Add -ffast-math.
* gcc.dg/graphite/interchange-1.c: Fix format.
* gcc.dg/graphite/interchange-10.c: New.
2009-10-05 Sebastian Pop <sebastian.pop@amd.com>
* graphite-sese-to-poly.c (insert_out_of_ssa_copy): Remove
buggy assert.
......
......@@ -585,6 +585,15 @@ graphite_legal_transform_dr (poly_bb_p pbb1, poly_bb_p pbb2,
return is_empty_p;
}
/* Return true when the data dependence relation for PBB1 and PBB2 is
part of a reduction. */
static inline bool
reduction_ddr (poly_bb_p pbb1, poly_bb_p pbb2)
{
return pbb1 == pbb2 && PBB_IS_REDUCTION (pbb1);
}
/* Iterates over the data references of PBB1 and PBB2 and detect
whether the transformed schedule is correct. */
......@@ -600,6 +609,9 @@ graphite_legal_transform_bb (poly_bb_p pbb1, poly_bb_p pbb2)
if (!PBB_PDR_DUPLICATES_REMOVED (pbb2))
pbb_remove_duplicate_pdrs (pbb2);
if (reduction_ddr (pbb1, pbb2))
return true;
for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), i, pdr1); i++)
for (j = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), j, pdr2); j++)
if (!graphite_legal_transform_dr (pbb1, pbb2, pdr1, pdr2))
......
......@@ -337,7 +337,7 @@ free_poly_dr (poly_dr_p pdr)
/* Create a new polyhedral black box. */
void
new_poly_bb (scop_p scop, void *black_box)
new_poly_bb (scop_p scop, void *black_box, bool reduction)
{
poly_bb_p pbb = XNEW (struct poly_bb);
......@@ -348,6 +348,7 @@ new_poly_bb (scop_p scop, void *black_box)
PBB_SAVED (pbb) = NULL;
PBB_ORIGINAL (pbb) = NULL;
PBB_DRS (pbb) = VEC_alloc (poly_dr_p, heap, 3);
PBB_IS_REDUCTION (pbb) = reduction;
VEC_safe_push (poly_bb_p, heap, SCOP_BBS (scop), pbb);
}
......
......@@ -306,6 +306,9 @@ struct poly_bb
/* True when the PDR duplicates have already been removed. */
bool pdr_duplicates_removed;
/* True when this PBB contains only a reduction statement. */
bool is_reduction;
};
#define PBB_BLACK_BOX(PBB) ((gimple_bb_p) PBB->black_box)
......@@ -320,8 +323,9 @@ struct poly_bb
#define PBB_NB_LOCAL_VARIABLES(PBB) (PBB->transformed->nb_local_variables)
#define PBB_NB_SCATTERING_TRANSFORM(PBB) (PBB->transformed->nb_scattering)
#define PBB_PDR_DUPLICATES_REMOVED(PBB) (PBB->pdr_duplicates_removed)
#define PBB_IS_REDUCTION(PBB) (PBB->is_reduction)
extern void new_poly_bb (scop_p, void *);
extern void new_poly_bb (scop_p, void *, bool);
extern void free_poly_bb (poly_bb_p);
extern void debug_loop_vec (poly_bb_p);
extern void schedule_to_scattering (poly_bb_p, int);
......
......@@ -21,7 +21,5 @@ along with GCC; see the file COPYING3. If not see
extern void build_scops (VEC (scop_p, heap) **);
extern void build_scop_bbs (scop_p);
extern int nb_reductions_in_loop (loop_p);
extern void dot_all_scops (VEC (scop_p, heap) *);
extern void dot_scop (scop_p);
......@@ -188,6 +188,33 @@ sese_loop_depth (sese region, loop_p loop)
return depth;
}
/* Splits BB to make a single entry single exit region. */
static inline sese
split_region_for_bb (basic_block bb)
{
edge entry, exit;
if (single_pred_p (bb))
entry = single_pred_edge (bb);
else
{
entry = split_block_after_labels (bb);
bb = single_succ (bb);
}
if (single_succ_p (bb))
exit = single_succ_edge (bb);
else
{
gimple_stmt_iterator gsi = gsi_last_bb (bb);
gsi_prev (&gsi);
exit = split_block (bb, gsi_stmt (gsi));
}
return new_sese (entry, exit);
}
/* Returns the block preceding the entry of a SESE. */
static inline basic_block
......
......@@ -55,7 +55,7 @@ dg-runtest $id_files "" $DEFAULT_CFLAGS_GRAPHITE_IDENTITY
foreach id_file $id_files {lremove wait_to_run_files $id_file}
# Flags using for interchange-* files.
set DEFAULT_CFLAGS_GRAPHITE_BLOCK "-O2 -fdump-tree-graphite-all -floop-interchange"
set DEFAULT_CFLAGS_GRAPHITE_BLOCK "-O2 -fdump-tree-graphite-all -floop-interchange -ffast-math"
set interchange_files [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.c ] ]
dg-runtest $interchange_files "" $DEFAULT_CFLAGS_GRAPHITE_BLOCK
foreach interchange_file $interchange_files {lremove wait_to_run_files $interchange_file}
......
......@@ -12,11 +12,11 @@ int foo(int N, int *res)
{
for (j = 0; j < N; j++)
sum = sum + u[i + 1335 * j];
u[1336 * i] *= 2;
}
*res = sum + N;
}
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */
/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
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