mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-16 13:01:21 +08:00
reject loops early where ivs cannot be represented
From-SVN: r228403
This commit is contained in:
parent
cce7865c1a
commit
000051e1c5
@ -1,3 +1,17 @@
|
||||
2015-10-02 Aditya Kumar <aditya.k7@samsung.com>
|
||||
|
||||
* graphite-scop-detection.c (loop_ivs_can_be_represented): New.
|
||||
(loop_body_is_valid_scop): Call loop_ivs_can_be_represented.
|
||||
* graphite-sese-to-poly.c (new_gimple_bb): Renamed new_gimple_poly_bb.
|
||||
(free_gimple_bb): Renamed free_gimple_poly_bb.
|
||||
(try_generate_gimple_bb): Hoist loop invariant code.
|
||||
(analyze_drs_in_stmts): Same.
|
||||
(build_scop_drs): Call renamed functions.
|
||||
(new_pbb_from_pbb): Same.
|
||||
(scop_ivs_can_be_represented): Delete as functionality now moved to
|
||||
graphite-scop-detection.c
|
||||
(build_poly_scop): Remove call to scop_ivs_can_be_represented.
|
||||
|
||||
2015-10-02 Aditya Kumar <hiraditya@msn.com>
|
||||
|
||||
* graphite-scop-detection.c (stmt_has_side_effects): New function
|
||||
|
@ -811,12 +811,40 @@ dot_scop (scop_p scop)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Can all ivs be represented by a signed integer?
|
||||
As ISL might generate negative values in its expressions, signed loop ivs
|
||||
are required in the backend. */
|
||||
|
||||
static bool
|
||||
loop_ivs_can_be_represented (loop_p loop)
|
||||
{
|
||||
for (gphi_iterator psi = gsi_start_phis (loop->header);
|
||||
!gsi_end_p (psi); gsi_next (&psi))
|
||||
{
|
||||
gphi *phi = psi.phi ();
|
||||
tree res = PHI_RESULT (phi);
|
||||
tree type = TREE_TYPE (res);
|
||||
|
||||
if (TYPE_UNSIGNED (type)
|
||||
&& TYPE_PRECISION (type) >= TYPE_PRECISION (long_long_integer_type_node))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Return true when the body of LOOP has statements that can be represented as a
|
||||
valid scop. */
|
||||
|
||||
static bool
|
||||
loop_body_is_valid_scop (loop_p loop, sese_l scop)
|
||||
{
|
||||
if (!loop_ivs_can_be_represented (loop))
|
||||
{
|
||||
DEBUG_PRINT (dp << "[scop-detection-fail] loop_"
|
||||
<< loop->num << "IV cannot be represented.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!loop_nest_has_data_refs (loop))
|
||||
{
|
||||
DEBUG_PRINT (dp << "[scop-detection-fail] loop_"
|
||||
|
@ -199,7 +199,7 @@ reduction_phi_p (sese region, gphi_iterator *psi)
|
||||
/* Store the GRAPHITE representation of BB. */
|
||||
|
||||
static gimple_poly_bb_p
|
||||
new_gimple_bb (basic_block bb, vec<data_reference_p> drs)
|
||||
new_gimple_poly_bb (basic_block bb, vec<data_reference_p> drs)
|
||||
{
|
||||
gimple_poly_bb_p gbb;
|
||||
|
||||
@ -233,7 +233,7 @@ free_data_refs_aux (vec<data_reference_p> datarefs)
|
||||
/* Frees GBB. */
|
||||
|
||||
static void
|
||||
free_gimple_bb (gimple_poly_bb_p gbb)
|
||||
free_gimple_poly_bb (gimple_poly_bb_p gbb)
|
||||
{
|
||||
free_data_refs_aux (GBB_DATA_REFS (gbb));
|
||||
free_data_refs (GBB_DATA_REFS (gbb));
|
||||
@ -253,7 +253,7 @@ remove_gbbs_in_scop (scop_p scop)
|
||||
poly_bb_p pbb;
|
||||
|
||||
FOR_EACH_VEC_ELT (SCOP_BBS (scop), i, pbb)
|
||||
free_gimple_bb (PBB_BLACK_BOX (pbb));
|
||||
free_gimple_poly_bb (PBB_BLACK_BOX (pbb));
|
||||
}
|
||||
|
||||
/* Deletes all scops in SCOPS. */
|
||||
@ -283,25 +283,23 @@ try_generate_gimple_bb (scop_p scop, basic_block bb)
|
||||
vec<data_reference_p> drs;
|
||||
drs.create (5);
|
||||
sese region = SCOP_REGION (scop);
|
||||
loop_p nest = outermost_loop_in_sese (region, bb);
|
||||
gimple_stmt_iterator gsi;
|
||||
|
||||
loop_p nest = outermost_loop_in_sese (region, bb);
|
||||
loop_p loop = bb->loop_father;
|
||||
if (!loop_in_sese_p (loop, region))
|
||||
loop = nest;
|
||||
|
||||
gimple_stmt_iterator gsi;
|
||||
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
||||
{
|
||||
gimple *stmt = gsi_stmt (gsi);
|
||||
loop_p loop;
|
||||
|
||||
if (is_gimple_debug (stmt))
|
||||
continue;
|
||||
|
||||
loop = loop_containing_stmt (stmt);
|
||||
if (!loop_in_sese_p (loop, region))
|
||||
loop = nest;
|
||||
|
||||
graphite_find_data_references_in_stmt (nest, loop, stmt, &drs);
|
||||
}
|
||||
|
||||
return new_gimple_bb (bb, drs);
|
||||
return new_gimple_poly_bb (bb, drs);
|
||||
}
|
||||
|
||||
/* Returns true if all predecessors of BB, that are not dominated by BB, are
|
||||
@ -1861,7 +1859,7 @@ build_scop_drs (scop_p scop)
|
||||
for (i = 0; SCOP_BBS (scop).iterate (i, &pbb); i++)
|
||||
if (GBB_DATA_REFS (PBB_BLACK_BOX (pbb)).is_empty ())
|
||||
{
|
||||
free_gimple_bb (PBB_BLACK_BOX (pbb));
|
||||
free_gimple_poly_bb (PBB_BLACK_BOX (pbb));
|
||||
free_poly_bb (pbb);
|
||||
SCOP_BBS (scop).ordered_remove (i);
|
||||
i--;
|
||||
@ -1909,19 +1907,18 @@ analyze_drs_in_stmts (scop_p scop, basic_block bb, vec<gimple *> stmts)
|
||||
return;
|
||||
|
||||
nest = outermost_loop_in_sese (region, bb);
|
||||
|
||||
loop_p loop = bb->loop_father;
|
||||
if (!loop_in_sese_p (loop, region))
|
||||
loop = nest;
|
||||
|
||||
gbb = gbb_from_bb (bb);
|
||||
|
||||
FOR_EACH_VEC_ELT (stmts, i, stmt)
|
||||
{
|
||||
loop_p loop;
|
||||
|
||||
if (is_gimple_debug (stmt))
|
||||
continue;
|
||||
|
||||
loop = loop_containing_stmt (stmt);
|
||||
if (!loop_in_sese_p (loop, region))
|
||||
loop = nest;
|
||||
|
||||
graphite_find_data_references_in_stmt (nest, loop, stmt,
|
||||
&GBB_DATA_REFS (gbb));
|
||||
}
|
||||
@ -1983,7 +1980,7 @@ new_pbb_from_pbb (scop_p scop, poly_bb_p pbb, basic_block bb)
|
||||
vec<data_reference_p> drs;
|
||||
drs.create (3);
|
||||
gimple_poly_bb_p gbb = PBB_BLACK_BOX (pbb);
|
||||
gimple_poly_bb_p gbb1 = new_gimple_bb (bb, drs);
|
||||
gimple_poly_bb_p gbb1 = new_gimple_poly_bb (bb, drs);
|
||||
poly_bb_p pbb1 = new_poly_bb (scop, gbb1);
|
||||
int index, n = SCOP_BBS (scop).length ();
|
||||
|
||||
@ -2473,43 +2470,6 @@ nb_pbbs_in_loops (scop_p scop)
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Can all ivs be represented by a signed integer?
|
||||
As ISL might generate negative values in its expressions, signed loop ivs
|
||||
are required in the backend. */
|
||||
|
||||
static bool
|
||||
scop_ivs_can_be_represented (scop_p scop)
|
||||
{
|
||||
loop_p loop;
|
||||
gphi_iterator psi;
|
||||
bool result = true;
|
||||
|
||||
FOR_EACH_LOOP (loop, 0)
|
||||
{
|
||||
if (!loop_in_sese_p (loop, SCOP_REGION (scop)))
|
||||
continue;
|
||||
|
||||
for (psi = gsi_start_phis (loop->header);
|
||||
!gsi_end_p (psi); gsi_next (&psi))
|
||||
{
|
||||
gphi *phi = psi.phi ();
|
||||
tree res = PHI_RESULT (phi);
|
||||
tree type = TREE_TYPE (res);
|
||||
|
||||
if (TYPE_UNSIGNED (type)
|
||||
&& TYPE_PRECISION (type) >= TYPE_PRECISION (long_long_integer_type_node))
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!result)
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Builds the polyhedral representation for a SESE region. */
|
||||
|
||||
void
|
||||
@ -2525,9 +2485,6 @@ build_poly_scop (scop_p scop)
|
||||
if (nb_pbbs_in_loops (scop) == 0)
|
||||
return;
|
||||
|
||||
if (!scop_ivs_can_be_represented (scop))
|
||||
return;
|
||||
|
||||
build_sese_loop_nests (region);
|
||||
/* Record all conditions in REGION. */
|
||||
sese_dom_walker (CDI_DOMINATORS, region).walk (cfun->cfg->x_entry_block_ptr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user