summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDorit Nuzman <dorit@il.ibm.com>2007-09-07 15:00:11 +0000
committerDorit Nuzman <dorit@gcc.gnu.org>2007-09-07 15:00:11 +0000
commit71f4a02318f4dad261ad8c8e9f77cd36e83f46e3 (patch)
treeeb44856e6a9b109989f0270786b08e7349ebe9dc
parentccf64c833ffaa36f74940afcdaef57a688bb4dcf (diff)
downloadgcc-71f4a02318f4dad261ad8c8e9f77cd36e83f46e3.tar.gz
re PR tree-optimization/33299 (miscompilation with gfortran -O2 -ffast-math -ftree-vectorize)
PR tree-optimization/33299 * tree-vect-transform.c (vect_create_epilog_for_reduction): Update uses for all relevant loop-exit phis, not just the first. From-SVN: r128242
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gfortran.dg/vect/fast-math-pr33299.f9017
-rw-r--r--gcc/testsuite/gfortran.dg/vect/vect.exp8
-rw-r--r--gcc/tree-vect-transform.c54
5 files changed, 61 insertions, 30 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a63a9e9748d..52dd1492603 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-09-07 Dorit Nuzman <dorit@il.ibm.com>
+
+ PR tree-optimization/33299
+ * tree-vect-transform.c (vect_create_epilog_for_reduction): Update uses
+ for all relevant loop-exit phis, not just the first.
+
2007-09-07 Richard Guenther <rguenther@suse.de>
PR middle-end/33330
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 772bcf39d07..13ab39940a9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2007-09-07 Dorit Nuzman <dorit@il.ibm.com>
+
+ PR tree-optimization/33299
+ * gfortran.dg/vect/vect.exp: Compile some tests with -ffast-math.
+ * gfortran.dg/vect/fast-math-pr33299.f90: New test.
+
2007-09-07 Richard Guenther <rguenther@suse.de>
Revert
diff --git a/gcc/testsuite/gfortran.dg/vect/fast-math-pr33299.f90 b/gcc/testsuite/gfortran.dg/vect/fast-math-pr33299.f90
new file mode 100644
index 00000000000..1de184dba40
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/vect/fast-math-pr33299.f90
@@ -0,0 +1,17 @@
+! { dg-require-effective-target vect_double }
+
+PROGRAM test
+ REAL(8) :: f,dist(2)
+ dist = [1.0_8, 0.5_8]
+ if( f(1.0_8, dist) /= MINVAL(dist)) then
+ call abort ()
+ endif
+END PROGRAM test
+
+FUNCTION f( x, dist ) RESULT(s)
+ REAL(8) :: dist(2), x, s
+ s = MINVAL(dist)
+ IF( x < 0 ) s = -s
+END FUNCTION f
+
+! { dg-final { cleanup-tree-dump "vect" } }
diff --git a/gcc/testsuite/gfortran.dg/vect/vect.exp b/gcc/testsuite/gfortran.dg/vect/vect.exp
index 3cc41c70482..74b064417b6 100644
--- a/gcc/testsuite/gfortran.dg/vect/vect.exp
+++ b/gcc/testsuite/gfortran.dg/vect/vect.exp
@@ -91,12 +91,18 @@ dg-init
# Main loop.
gfortran-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/vect-*.\[fF\]{,90,95,03} ]] $DEFAULT_VECTCFLAGS
-gfortran-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr-*.\[fF\]{,90,95,03} ]] $DEFAULT_VECTCFLAGS
+gfortran-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr*.\[fF\]{,90,95,03} ]] $DEFAULT_VECTCFLAGS
#### Tests with special options
global SAVED_DEFAULT_VECTCFLAGS
set SAVED_DEFAULT_VECTCFLAGS $DEFAULT_VECTCFLAGS
+# -ffast-math tests
+set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
+lappend DEFAULT_VECTCFLAGS "-ffast-math"
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/fast-math-*.\[fF\]{,90,95,03} ]] \
+ "" $DEFAULT_VECTCFLAGS
+
# --param vect-max-version-for-alias-checks=0 tests
set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
lappend DEFAULT_VECTCFLAGS "--param" "vect-max-version-for-alias-checks=0"
diff --git a/gcc/tree-vect-transform.c b/gcc/tree-vect-transform.c
index 321d3253419..cddebde26ad 100644
--- a/gcc/tree-vect-transform.c
+++ b/gcc/tree-vect-transform.c
@@ -1964,6 +1964,8 @@ vect_create_epilog_for_reduction (tree vect_def, tree stmt,
tree operation = GIMPLE_STMT_OPERAND (stmt, 1);
bool nested_in_vect_loop = false;
int op_type;
+ VEC(tree,heap) *phis = NULL;
+ int i;
if (nested_in_vect_loop_p (loop, stmt))
{
@@ -2260,11 +2262,7 @@ vect_finalize_reduction:
epilog_stmt = build_gimple_modify_stmt (new_dest, expr);
new_temp = make_ssa_name (new_dest, epilog_stmt);
GIMPLE_STMT_OPERAND (epilog_stmt, 0) = new_temp;
-#if 0
- bsi_insert_after (&exit_bsi, epilog_stmt, BSI_NEW_STMT);
-#else
bsi_insert_before (&exit_bsi, epilog_stmt, BSI_SAME_STMT);
-#endif
}
@@ -2274,45 +2272,43 @@ vect_finalize_reduction:
Find the loop-closed-use at the loop exit of the original scalar result.
(The reduction result is expected to have two immediate uses - one at the
latch block, and one at the loop exit). */
- exit_phi = NULL;
+ phis = VEC_alloc (tree, heap, 10);
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, scalar_dest)
{
if (!flow_bb_inside_loop_p (loop, bb_for_stmt (USE_STMT (use_p))))
{
exit_phi = USE_STMT (use_p);
- break;
+ VEC_quick_push (tree, phis, exit_phi);
}
}
/* We expect to have found an exit_phi because of loop-closed-ssa form. */
- gcc_assert (exit_phi);
+ gcc_assert (!VEC_empty (tree, phis));
- if (nested_in_vect_loop)
+ for (i = 0; VEC_iterate (tree, phis, i, exit_phi); i++)
{
- stmt_vec_info stmt_vinfo = vinfo_for_stmt (exit_phi);
+ if (nested_in_vect_loop)
+ {
+ stmt_vec_info stmt_vinfo = vinfo_for_stmt (exit_phi);
- /* FORNOW. Currently not supporting the case that an inner-loop reduction
- is not used in the outer-loop (but only outside the outer-loop). */
- gcc_assert (STMT_VINFO_RELEVANT_P (stmt_vinfo)
- && !STMT_VINFO_LIVE_P (stmt_vinfo));
+ /* FORNOW. Currently not supporting the case that an inner-loop reduction
+ is not used in the outer-loop (but only outside the outer-loop). */
+ gcc_assert (STMT_VINFO_RELEVANT_P (stmt_vinfo)
+ && !STMT_VINFO_LIVE_P (stmt_vinfo));
- epilog_stmt = adjustment_def ? epilog_stmt : new_phi;
- STMT_VINFO_VEC_STMT (stmt_vinfo) = epilog_stmt;
- set_stmt_info (get_stmt_ann (epilog_stmt),
- new_stmt_vec_info (epilog_stmt, loop_vinfo));
+ epilog_stmt = adjustment_def ? epilog_stmt : new_phi;
+ STMT_VINFO_VEC_STMT (stmt_vinfo) = epilog_stmt;
+ set_stmt_info (get_stmt_ann (epilog_stmt),
+ new_stmt_vec_info (epilog_stmt, loop_vinfo));
+ continue;
+ }
- if (vect_print_dump_info (REPORT_DETAILS))
- {
- fprintf (vect_dump, "vector of partial results after inner-loop:");
- print_generic_expr (vect_dump, epilog_stmt, TDF_SLIM);
- }
- return;
+ /* Replace the uses: */
+ orig_name = PHI_RESULT (exit_phi);
+ FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, orig_name)
+ FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
+ SET_USE (use_p, new_temp);
}
-
- /* Replace the uses: */
- orig_name = PHI_RESULT (exit_phi);
- FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, orig_name)
- FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
- SET_USE (use_p, new_temp);
+ VEC_free (tree, heap, phis);
}