2014-02-04 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Feb 2014 09:34:58 +0000 (09:34 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Feb 2014 09:34:58 +0000 (09:34 +0000)
PR tree-optimization/60012
* tree-vect-data-refs.c (vect_analyze_data_ref_dependence): Apply
TBAA disambiguation to all DDRs.

* gcc.dg/vect/pr60012.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207455 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr60012.c [new file with mode: 0644]
gcc/tree-vect-data-refs.c

index cd8acae..93a502f 100644 (file)
@@ -1,3 +1,9 @@
+2014-02-04  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60012
+       * tree-vect-data-refs.c (vect_analyze_data_ref_dependence): Apply
+       TBAA disambiguation to all DDRs.
+
 2014-02-04  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        PR target/59788
index 3c7682f..f630cd9 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-04  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60012
+       * gcc.dg/vect/pr60012.c: New testcase.
+
 2014-02-04  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        PR target/59788
diff --git a/gcc/testsuite/gcc.dg/vect/pr60012.c b/gcc/testsuite/gcc.dg/vect/pr60012.c
new file mode 100644 (file)
index 0000000..2f73799
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-additional-options "--param vect-max-version-for-alias-checks=0" } */
+
+typedef struct
+{
+  short real;
+  short imag;
+} complex16_t;
+
+void
+libvector_AccSquareNorm_ref (unsigned long long  *acc,
+                            const complex16_t *x, unsigned len)
+{
+  unsigned i;
+  for (i = 0; i < len; i++)
+    acc[i] += ((unsigned long long)((int)x[i].real * x[i].real))
+       + ((unsigned long long)((int)x[i].imag * x[i].imag));
+}
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
index c3e8f37..d018add 100644 (file)
@@ -235,6 +235,18 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
       || (DR_IS_READ (dra) && DR_IS_READ (drb)))
     return false;
 
+  /* Even if we have an anti-dependence then, as the vectorized loop covers at
+     least two scalar iterations, there is always also a true dependence.
+     As the vectorizer does not re-order loads and stores we can ignore
+     the anti-dependence if TBAA can disambiguate both DRs similar to the
+     case with known negative distance anti-dependences (positive
+     distance anti-dependences would violate TBAA constraints).  */
+  if (((DR_IS_READ (dra) && DR_IS_WRITE (drb))
+       || (DR_IS_WRITE (dra) && DR_IS_READ (drb)))
+      && !alias_sets_conflict_p (get_alias_set (DR_REF (dra)),
+                                get_alias_set (DR_REF (drb))))
+    return false;
+
   /* Unknown data dependence.  */
   if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know)
     {