aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIra Rosen <irar@il.ibm.com>2007-03-11 11:13:34 +0000
committerIra Rosen <irar@gcc.gnu.org>2007-03-11 11:13:34 +0000
commite838422b9eee3123812624de39ed76259e212492 (patch)
treea0d2e2a93834af978e8625b3a711d9c1a40ab9d8
parent7b8cd03d6990e75f2f3286db9dda977ef6017bee (diff)
downloadgcc-e838422b9eee3123812624de39ed76259e212492.zip
gcc-e838422b9eee3123812624de39ed76259e212492.tar.gz
gcc-e838422b9eee3123812624de39ed76259e212492.tar.bz2
tree-data-ref.c (analyze_offset): Add a return value (bool) to indicate success/failure of the analysis.
* tree-data-ref.c (analyze_offset): Add a return value (bool) to indicate success/failure of the analysis. Add negation to subtrahend in case of subtraction. Fail if both operands contain constants. (create_data_ref): Fail if analyze_offset fails. From-SVN: r122817
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/vect/fast-math-vect-pr29925.c39
-rw-r--r--gcc/tree-data-ref.c37
4 files changed, 81 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f726f3e..1bdc306 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2007-03-11 Ira Rosen <irar@il.ibm.com>
+
+ * tree-data-ref.c (analyze_offset): Add a return value (bool) to
+ indicate success/failure of the analysis. Add negation to subtrahend
+ in case of subtraction. Fail if both operands contain constants.
+ (create_data_ref): Fail if analyze_offset fails.
+
2007-03-11 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.md (frndintxf2): Rename to ...
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index edc908c..ac53f61 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-03-11 Ira Rosen <irar@il.ibm.com>
+
+ PR tree-optimization/29925
+ * gcc.dg/vect/fast-math-vect-pr29925.c: New test.
+
2007-03-10 Mark Mitchell <mark@codesourcery.com>
PR c++/30274
diff --git a/gcc/testsuite/gcc.dg/vect/fast-math-vect-pr29925.c b/gcc/testsuite/gcc.dg/vect/fast-math-vect-pr29925.c
new file mode 100644
index 0000000..caa6a3c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/fast-math-vect-pr29925.c
@@ -0,0 +1,39 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdlib.h>
+#include "tree-vect.h"
+
+void interp_pitch(float *exc, float *interp, int pitch, int len)
+{
+ int i,k;
+ int maxj;
+
+ maxj=3;
+ for (i=0;i<len;i++)
+ {
+ float tmp = 0;
+ for (k=0;k<7;k++)
+ {
+ tmp += exc[i-pitch+k+maxj-6];
+ }
+ interp[i] = tmp;
+ }
+}
+
+int main()
+{
+ float *exc = calloc(126,sizeof(float));
+ float *interp = calloc(80,sizeof(float));
+ int pitch = -35;
+
+ check_vect ();
+
+ interp_pitch(exc, interp, pitch, 80);
+ free(exc);
+ free(interp);
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 7eadde7..d59278c 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -1835,7 +1835,7 @@ object_analysis (tree memref, tree stmt, bool is_read,
Extract INVARIANT and CONSTANT parts from OFFSET.
*/
-static void
+static bool
analyze_offset (tree offset, tree *invariant, tree *constant)
{
tree op0, op1, constant_0, constant_1, invariant_0, invariant_1;
@@ -1851,23 +1851,36 @@ analyze_offset (tree offset, tree *invariant, tree *constant)
*constant = offset;
else
*invariant = offset;
- return;
+ return true;
}
op0 = TREE_OPERAND (offset, 0);
op1 = TREE_OPERAND (offset, 1);
/* Recursive call with the operands. */
- analyze_offset (op0, &invariant_0, &constant_0);
- analyze_offset (op1, &invariant_1, &constant_1);
+ if (!analyze_offset (op0, &invariant_0, &constant_0)
+ || !analyze_offset (op1, &invariant_1, &constant_1))
+ return false;
- /* Combine the results. */
+ /* Combine the results. Add negation to the subtrahend in case of
+ subtraction. */
+ if (constant_0 && constant_1)
+ return false;
*constant = constant_0 ? constant_0 : constant_1;
+ if (code == MINUS_EXPR && constant_1)
+ *constant = fold_build1 (NEGATE_EXPR, TREE_TYPE (*constant), *constant);
+
if (invariant_0 && invariant_1)
*invariant =
fold_build2 (code, TREE_TYPE (invariant_0), invariant_0, invariant_1);
else
- *invariant = invariant_0 ? invariant_0 : invariant_1;
+ {
+ *invariant = invariant_0 ? invariant_0 : invariant_1;
+ if (code == MINUS_EXPR && invariant_1)
+ *invariant =
+ fold_build1 (NEGATE_EXPR, TREE_TYPE (*invariant), *invariant);
+ }
+ return true;
}
/* Free the memory used by the data reference DR. */
@@ -1941,7 +1954,17 @@ create_data_ref (tree memref, tree stmt, bool is_read)
STRIP_NOPS (offset);
if (offset != orig_offset)
type = TREE_TYPE (orig_offset);
- analyze_offset (offset, &invariant, &constant);
+ if (!analyze_offset (offset, &invariant, &constant))
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "\ncreate_data_ref: failed to analyze dr's");
+ fprintf (dump_file, " offset for ");
+ print_generic_expr (dump_file, memref, TDF_SLIM);
+ fprintf (dump_file, "\n");
+ }
+ return NULL;
+ }
if (type && invariant)
invariant = fold_convert (type, invariant);