summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2009-08-12 14:32:31 +0000
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2009-08-12 14:32:31 +0000
commit43f8b6ab45c2d28a495a346f7313bf7fd51ea0c6 (patch)
tree283fef24a62d6d0e162a392a4ac2a0c78b3137b3 /gcc
parent96da199905fa010321a8dbcef99ab15ceb1ff517 (diff)
downloadgcc-43f8b6ab45c2d28a495a346f7313bf7fd51ea0c6.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150694 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/ChangeLog.graphite8
-rw-r--r--gcc/sese.c50
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/graphite/id-17.f16
5 files changed, 66 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3280919183c..bf7518ea8a7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
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
unknown subscript upper bounds.
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index cb67b31c026..1a0e3fa1554 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,13 @@
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
unknown subscript upper bounds.
diff --git a/gcc/sese.c b/gcc/sese.c
index 25c5703ec71..394d465f098 100644
--- a/gcc/sese.c
+++ b/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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8eace450023..02148b6275f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
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.
2009-08-12 Sebastian Pop <sebastian.pop@amd.com>
diff --git a/gcc/testsuite/gfortran.dg/graphite/id-17.f b/gcc/testsuite/gfortran.dg/graphite/id-17.f
new file mode 100644
index 00000000000..4bebed01678
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/graphite/id-17.f
@@ -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