Prepare expressions to be good phi arguments.
2009-08-11 Sebastian Pop <sebastian.pop@amd.com> PR middle-end/40980 * sese.c (convert_for_phi_arg): New. (add_guard_exit_phis): Use convert_for_phi_arg. * testsuite/gfortran.dg/graphite/id-17.f: New. From-SVN: r150694
This commit is contained in:
parent
8c31ebfa3a
commit
30de16328a
@ -1,3 +1,9 @@
|
||||
2009-08-12 Sebastian Pop <sebastian.pop@amd.com>
|
||||
|
||||
PR middle-end/40980
|
||||
* sese.c (convert_for_phi_arg): New.
|
||||
(add_guard_exit_phis): Use convert_for_phi_arg.
|
||||
|
||||
2009-08-12 Sebastian Pop <sebastian.pop@amd.com>
|
||||
|
||||
* graphite-sese-to-poly.c (pdr_add_data_dimensions): Dont add
|
||||
|
@ -1,3 +1,11 @@
|
||||
2009-08-11 Sebastian Pop <sebastian.pop@amd.com>
|
||||
|
||||
PR middle-end/40980
|
||||
* sese.c (convert_for_phi_arg): New.
|
||||
(add_guard_exit_phis): Use convert_for_phi_arg.
|
||||
|
||||
* testsuite/gfortran.dg/graphite/id-17.f: New.
|
||||
|
||||
2009-08-11 Sebastian Pop <sebastian.pop@amd.com>
|
||||
|
||||
* graphite-sese-to-poly.c (pdr_add_data_dimensions): Dont add
|
||||
|
50
gcc/sese.c
50
gcc/sese.c
@ -1085,6 +1085,31 @@ default_before_guard (htab_t before_guard, tree old_name)
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Prepares EXPR to be a good phi argument when the phi result is
|
||||
RES. Insert needed statements on edge E. */
|
||||
|
||||
static tree
|
||||
convert_for_phi_arg (tree expr, tree res, edge e)
|
||||
{
|
||||
tree type = TREE_TYPE (res);
|
||||
|
||||
if (TREE_TYPE (expr) != type)
|
||||
expr = fold_convert (type, expr);
|
||||
|
||||
if (TREE_CODE (expr) != SSA_NAME
|
||||
&& !is_gimple_min_invariant (expr))
|
||||
{
|
||||
tree var = create_tmp_var (type, "var");
|
||||
gimple_seq stmts;
|
||||
|
||||
expr = build2 (MODIFY_EXPR, type, var, expr);
|
||||
expr = force_gimple_operand (expr, &stmts, true, NULL);
|
||||
gsi_insert_seq_on_edge_immediate (e, stmts);
|
||||
}
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
/* Helper function for htab_traverse in insert_guard_phis. */
|
||||
|
||||
static int
|
||||
@ -1095,33 +1120,20 @@ add_guard_exit_phis (void **slot, void *s)
|
||||
basic_block bb = i->bb;
|
||||
edge true_edge = i->true_edge;
|
||||
edge false_edge = i->false_edge;
|
||||
tree res = entry->old_name;
|
||||
tree name1 = entry->expr;
|
||||
tree name2 = default_before_guard (i->before_guard, entry->old_name);
|
||||
tree name2 = default_before_guard (i->before_guard, res);
|
||||
gimple phi;
|
||||
tree res;
|
||||
gimple_seq stmts;
|
||||
|
||||
/* Nothing to be merged if the name before the guard is the same as
|
||||
the one after. */
|
||||
if (name1 == name2)
|
||||
return 1;
|
||||
|
||||
if (TREE_TYPE (name1) != TREE_TYPE (name2))
|
||||
name1 = fold_convert (TREE_TYPE (name2), name1);
|
||||
name1 = convert_for_phi_arg (name1, res, true_edge);
|
||||
name2 = convert_for_phi_arg (name2, res, false_edge);
|
||||
|
||||
if (TREE_CODE (name1) != SSA_NAME
|
||||
&& (TREE_CODE (name2) != SSA_NAME
|
||||
|| is_gimple_reg (name2)))
|
||||
{
|
||||
tree type = TREE_TYPE (name2);
|
||||
tree var = create_tmp_var (type, "var");
|
||||
|
||||
name1 = build2 (MODIFY_EXPR, type, var, name1);
|
||||
name1 = force_gimple_operand (name1, &stmts, true, NULL);
|
||||
gsi_insert_seq_on_edge_immediate (true_edge, stmts);
|
||||
}
|
||||
|
||||
phi = create_phi_node (entry->old_name, bb);
|
||||
phi = create_phi_node (res, bb);
|
||||
res = create_new_def_for (gimple_phi_result (phi), phi,
|
||||
gimple_phi_result_ptr (phi));
|
||||
|
||||
@ -1136,7 +1148,7 @@ add_guard_exit_phis (void **slot, void *s)
|
||||
/* Iterate over RENAME_MAP and get tuples of the form (OLD, NAME1).
|
||||
If there is a correspondent tuple (OLD, NAME2) in BEFORE_GUARD,
|
||||
with NAME1 different than NAME2, then insert in BB the phi node:
|
||||
|
||||
|
||||
| RES = phi (NAME1 (on TRUE_EDGE), NAME2 (on FALSE_EDGE))"
|
||||
|
||||
if there is no tuple for OLD in BEFORE_GUARD, insert
|
||||
|
@ -1,3 +1,8 @@
|
||||
2009-08-12 Sebastian Pop <sebastian.pop@amd.com>
|
||||
|
||||
PR middle-end/40980
|
||||
* testsuite/gfortran.dg/graphite/id-17.f: New.
|
||||
|
||||
2009-08-12 Sebastian Pop <sebastian.pop@amd.com>
|
||||
|
||||
* testsuite/gcc.dg/graphite/interchange-6.c: Un-XFAIL.
|
||||
|
16
gcc/testsuite/gfortran.dg/graphite/id-17.f
Normal file
16
gcc/testsuite/gfortran.dg/graphite/id-17.f
Normal file
@ -0,0 +1,16 @@
|
||||
SUBROUTINE SPECTOP(Dr,N)
|
||||
DIMENSION d1(0:32,0:32) , Dr(0:32,0:32) , x(0:32)
|
||||
DO k = 0 , N
|
||||
fctr2 = o
|
||||
DO j = 0 , N
|
||||
fctr = fctr1*fctr2
|
||||
IF ( j.NE.k ) THEN
|
||||
d1(k,j) = ck*fctr/(cj*(x(k)-x(j)))
|
||||
ENDIF
|
||||
fctr2 = -o*fctr2
|
||||
ENDDO
|
||||
DO j = 0 , N
|
||||
Dr(k,j) = d1(N-k,N-j)
|
||||
ENDDO
|
||||
ENDDO
|
||||
END
|
Loading…
Reference in New Issue
Block a user