public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [4.3 projects] Verctorizer - versioning for alias
@ 2007-08-14 11:02 Victor Kaplansky
  2007-08-14 11:38 ` Zdenek Dvorak
  2007-08-14 17:07 ` Dorit Nuzman
  0 siblings, 2 replies; 10+ messages in thread
From: Victor Kaplansky @ 2007-08-14 11:02 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 3093 bytes --]


Often it is impossible to alias analysis to prove dependency or
independency.  In such cases vectorizer is bound to be conservative.
However in many cases at run-time we can validate the independence
by testing that data reference ranges are not overlapped.

This patch enhances the vectorizer by introducing run-time checks
and loop versioning to take advantage of vectorized loop in case when
data reference independence can be proved at run-time.  The number
of added data reference test can be controlled by
"vect-max-version-for-alias-checks" parameter.  The value of 0 will
disable the versioning for alias.  Then maximum number of checks
produced for versioning for alignment can now be controlled by
"vect-max-version-for-alignment-checks".

Bootstrapped and regtested on ppc64 and x86_64.
Bootstrapped with vectorization enabled on x86_64.
Okay for mainline?

2007-08-14  Victor Kaplansky <victork@il.ibm.com>

ChangeLog:

             * tree-vectorizer.c (new_loop_vec_info): Initialize new
             field.
             (destroy_loop_vec_info): Add call to VEC_free.
             * tree-vectorizer.h (may_alias_ddrs): Define.
             (LOOP_VINFO_MAY_ALIAS_DDRS): Define.
             * tree-vect-analyze.c (vect_analyze_data_ref_dependence):
             Change reporting to dump.
             (vect_is_duplicate_ddr): New.
             (vect_mark_for_runtime_alias_test): New.
             (vect_analyze_data_ref_dependences) Add call to
             vect_mark_for_runtime_alias_test.
             (vect_enhance_data_refs_alignment): Define local variable
             vect_versioning_for_alias_required, don't perform
             versioning for alignment if versioning for alias is
             required.
             (vect_enhance_data_refs_alignment): Use
             PARAM_VECT_MAX_VERSION_FOR_ALIGNMENT_CHECKS instead of
             PARAM_VECT_MAX_VERSION_CHECKS.
             * tree-vect-transform.c (vect_create_cond_for_alias_checks):
             New.
             (vect_transform_loop): Add call to
             vect_create_cond_for_alias_checks.
             * params.def (PARAM_VECT_MAX_VERSION_FOR_ALIGNMENT_CHECKS):
             Rename.
             (PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS): Define.

testsuite/ChangeLog:

            * gcc.dg/vect/vect-vfa-01.c: New.
            * gcc.dg/vect/vect-vfa-02.c: New.
            * gcc.dg/vect/vect-vfa-03.c: New.
            * gcc.dg/vect/vect-102a.c, gcc.dg/vect/vect-51.c,
            gcc.dg/vect/pr29145.c, gcc.dg/vect/vect-43.c,
            gcc.dg/vect/vect-61.c, gcc.dg/vect/vect-53.c,
            gcc.dg/vect/vect-45.c, gcc.dg/vect/vect-101.c,
            gcc.dg/vect/vect-37.c, gcc.dg/vect/vect-79.c,
            gcc.dg/vect/vect-102.c, gcc.dg/vect/vect-dv-2.c,
            gcc.dg/vect/vect-57.c, gcc.dg/vect/vect-49.c,
            gfortran.dg/vect/pr19049.f90: Rename to start with
            prefix no-vfa-.
            * gcc.dg/vect/vect.exp: Disable versioning for alias
            when test starts with no-vfa-.
            * gfortran.dg/vect/vect.exp: Likewise.

(See attached file: vfa.txt)

[-- Attachment #2: vfa.txt --]
[-- Type: text/plain, Size: 68243 bytes --]

Index: testsuite/gcc.dg/vect/vect-vfa-01.c
===================================================================
--- testsuite/gcc.dg/vect/vect-vfa-01.c	(revision 0)
+++ testsuite/gcc.dg/vect/vect-vfa-01.c	(revision 0)
@@ -0,0 +1,39 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+int result[N] = {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27};
+int X[N] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25};
+int Y[N] = {};
+ 
+void
+foo (int *in, int *out)
+{  
+  int i;
+  
+  for (i = 0; i < N; i++)
+    out[i] = in[i] + 2;
+}
+
+int
+main (void)
+{ 
+  int i;
+
+  check_vect ();
+
+  foo (X, Y);
+  
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (Y[i] != result[i])
+	abort ();
+    }
+  return 0;
+} 
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect-vfa-02.c
===================================================================
--- testsuite/gcc.dg/vect/vect-vfa-02.c	(revision 0)
+++ testsuite/gcc.dg/vect/vect-vfa-02.c	(revision 0)
@@ -0,0 +1,47 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+int resultY[N] = {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27};
+int resultZ[N] = {13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28};
+int X[N] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25};
+int Y[N] = {};
+int Z[N] = {};
+ 
+void
+foo (int *in, int *out1, int *out2)
+{
+  int i;
+
+  for (i = 0; i < N; i++)
+    {
+      out1[i] = in[i] + 2;
+      out2[i] = in[i] + 3;
+    }
+}
+
+int
+main (void)
+{ 
+  int i;
+
+  check_vect ();
+
+  foo (X, Y, Z);
+  
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (Y[i] != resultY[i])
+	abort ();
+
+      if (Z[i] != resultZ[i])
+	abort ();
+    }
+  return 0;
+} 
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect-vfa-03.c
===================================================================
--- testsuite/gcc.dg/vect/vect-vfa-03.c	(revision 0)
+++ testsuite/gcc.dg/vect/vect-vfa-03.c	(revision 0)
@@ -0,0 +1,58 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+struct S
+{
+  unsigned short a;
+  unsigned short b;
+};
+
+struct S result[N] = {12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18,
+                      18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24,
+		      24, 25, 25, 26, 26, 27, 27, 28};
+struct S X[N] = {10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16,
+                 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
+		 23, 23, 24, 24, 25, 25};
+struct S Y[N] = {};
+ 
+void
+foo (struct S * in, struct S * out)
+{
+  int i;
+
+  for (i = 0; i < N; i++)
+    {
+      out[i].a = in[i].a + 2;
+      out[i].b = in[i].b + 3;
+    }
+}
+
+int
+main (void)
+{ 
+  int i;
+
+  check_vect ();
+
+  foo (X, Y);
+  
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (Y[i].a != result[i].a)
+	abort ();
+
+      if (Y[i].b != result[i].b)
+	abort ();
+
+    }
+  return 0;
+} 
+
+/* Needs interleaving support.  */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_interleave && vect_extract_even_odd } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { xfail  { vect_interleave && vect_extract_even_odd } } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect.exp
===================================================================
--- testsuite/gcc.dg/vect/vect.exp	(revision 127316)
+++ testsuite/gcc.dg/vect/vect.exp	(working copy)
@@ -113,6 +113,12 @@
 global SAVED_DEFAULT_VECTCFLAGS
 set SAVED_DEFAULT_VECTCFLAGS $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"
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-vfa-*.\[cS\]]]  \
+	"" $DEFAULT_VECTCFLAGS
+
 # -ffast-math tests
 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
 lappend DEFAULT_VECTCFLAGS "-ffast-math"
Index: testsuite/gfortran.dg/vect/vect.exp
===================================================================
--- testsuite/gfortran.dg/vect/vect.exp	(revision 127316)
+++ testsuite/gfortran.dg/vect/vect.exp	(working copy)
@@ -90,8 +90,19 @@
 dg-init
 
 # Main loop.
-gfortran-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03} ]] $DEFAULT_VECTCFLAGS
+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
 
+#### Tests with special options
+global SAVED_DEFAULT_VECTCFLAGS
+set SAVED_DEFAULT_VECTCFLAGS $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"
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-vfa-*.\[fF\]{,90,95,03} ]]  \
+        "" $DEFAULT_VECTCFLAGS
+
 # Clean up.
 set dg-do-what-default ${save-dg-do-what-default}
 
Index: tree-vectorizer.c
===================================================================
--- tree-vectorizer.c	(revision 127316)
+++ tree-vectorizer.c	(working copy)
@@ -1414,9 +1414,12 @@
   LOOP_VINFO_DATAREFS (res) = VEC_alloc (data_reference_p, heap, 10);
   LOOP_VINFO_DDRS (res) = VEC_alloc (ddr_p, heap, 10 * 10);
   LOOP_VINFO_UNALIGNED_DR (res) = NULL;
-  LOOP_VINFO_MAY_MISALIGN_STMTS (res)
-    = VEC_alloc (tree, heap, PARAM_VALUE (PARAM_VECT_MAX_VERSION_CHECKS));
+  LOOP_VINFO_MAY_MISALIGN_STMTS (res) =
+    VEC_alloc (tree, heap, PARAM_VALUE (PARAM_VECT_MAX_VERSION_FOR_ALIGNMENT_CHECKS));
+  LOOP_VINFO_MAY_ALIAS_DDRS (res) =
+    VEC_alloc (ddr_p, heap, PARAM_VALUE (PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS));
 
+
   return res;
 }
 
@@ -1495,6 +1498,7 @@
   free_data_refs (LOOP_VINFO_DATAREFS (loop_vinfo));
   free_dependence_relations (LOOP_VINFO_DDRS (loop_vinfo));
   VEC_free (tree, heap, LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo));
+  VEC_free (ddr_p, heap, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo));
 
   free (loop_vinfo);
   loop->aux = NULL;
Index: tree-vectorizer.h
===================================================================
--- tree-vectorizer.h	(revision 127316)
+++ tree-vectorizer.h	(working copy)
@@ -133,6 +133,10 @@
   /* All data dependences in the loop.  */
   VEC (ddr_p, heap) *ddrs;
 
+  /* Data Dependence Relations defining address ranges that are candidates
+     for a run-time aliasing check.  */
+  VEC (ddr_p, heap) *may_alias_ddrs;
+
   /* Statements in the loop that have data references that are candidates for a
      runtime (loop versioning) misalignment check.  */
   VEC(tree,heap) *may_misalign_stmts;
@@ -157,6 +161,7 @@
 #define LOOP_VINFO_UNALIGNED_DR(L)    (L)->unaligned_dr
 #define LOOP_VINFO_MAY_MISALIGN_STMTS(L) (L)->may_misalign_stmts
 #define LOOP_VINFO_LOC(L)             (L)->loop_line_number
+#define LOOP_VINFO_MAY_ALIAS_DDRS(L)  (L)->may_alias_ddrs
 
 #define NITERS_KNOWN_P(n)                     \
 (host_integerp ((n),0)                        \
Index: tree-vect-analyze.c
===================================================================
--- tree-vect-analyze.c	(revision 127316)
+++ tree-vect-analyze.c	(working copy)
@@ -1039,10 +1039,10 @@
   
   if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know)
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
+      if (vect_print_dump_info (REPORT_DR_DETAILS))
         {
           fprintf (vect_dump,
-                   "not vectorized: can't determine dependence between ");
+                   "versioning for alias required: can't determine dependence between ");
           print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
           fprintf (vect_dump, " and ");
           print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
@@ -1052,9 +1052,9 @@
 
   if (DDR_NUM_DIST_VECTS (ddr) == 0)
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
+      if (vect_print_dump_info (REPORT_DR_DETAILS))
         {
-          fprintf (vect_dump, "not vectorized: bad dist vector for ");
+          fprintf (vect_dump, "versioning for alias required: bad dist vector for ");
           print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
           fprintf (vect_dump, " and ");
           print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
@@ -1108,10 +1108,10 @@
 	  continue;
 	}
 
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
+      if (vect_print_dump_info (REPORT_DR_DETAILS))
 	{
 	  fprintf (vect_dump,
-		   "not vectorized: possible dependence between data-refs ");
+		   "versioning for alias required: possible dependence between data-refs ");
 	  print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
 	  fprintf (vect_dump, " and ");
 	  print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
@@ -1123,7 +1123,76 @@
   return false;
 }
 
+/* Return TRUE if DDR_NEW is already found in MAY_ALIAS_DDRS list.  */
+static bool
+vect_is_duplicate_ddr (VEC (ddr_p, heap) * may_alias_ddrs, ddr_p ddr_new)
+{
+  unsigned i;
+  ddr_p ddr;
 
+  for (i = 0; VEC_iterate (ddr_p, may_alias_ddrs, i, ddr); i++)
+    {
+      tree dref_A_i, dref_B_i, dref_A_j, dref_B_j;
+
+      dref_A_i = DR_REF (DDR_A (ddr));
+      dref_B_i = DR_REF (DDR_B (ddr));
+      dref_A_j = DR_REF (DDR_A (ddr_new));
+      dref_B_j = DR_REF (DDR_B (ddr_new));
+
+      if ((operand_equal_p (dref_A_i, dref_A_j, 0)
+	   && operand_equal_p (dref_B_i, dref_B_j, 0))
+	  || (operand_equal_p (dref_A_i, dref_B_j, 0)
+	      && operand_equal_p (dref_B_i, dref_A_j, 0)))
+	{
+	  if (vect_print_dump_info (REPORT_DR_DETAILS))
+	    {
+	      fprintf (vect_dump, "found same pair of data references ");
+	      print_generic_expr (vect_dump, dref_A_i, TDF_SLIM);
+	      fprintf (vect_dump, " and ");
+	      print_generic_expr (vect_dump, dref_B_i, TDF_SLIM);
+	    }
+	  return true;
+	}
+    }
+  return false;
+}
+
+/* Save DDR in LOOP_VINFO list of ddrs that may alias and need to be
+   tested at run-time.  Returns false if number of run-time checks
+   iserted by vectorizer is greater than maximum defined by
+   PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS.  */
+static bool
+vect_mark_for_runtime_alias_test (ddr_p ddr, loop_vec_info loop_vinfo)
+{
+  if (vect_print_dump_info (REPORT_DR_DETAILS))
+    {
+      fprintf (vect_dump, "mark for run-time aliasing test between ");
+      print_generic_expr (vect_dump, DR_REF (DDR_A (ddr)), TDF_SLIM);
+      fprintf (vect_dump, " and ");
+      print_generic_expr (vect_dump, DR_REF (DDR_B (ddr)), TDF_SLIM);
+    }
+
+  /* Do not add to the list duplicate ddrs.  */
+  if (vect_is_duplicate_ddr (LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo), ddr))
+    return true;
+
+  if (VEC_length (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo))
+      >= (unsigned) PARAM_VALUE (PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS))
+    {
+      if (vect_print_dump_info (REPORT_DR_DETAILS))
+	{
+	  fprintf (vect_dump,
+		   "disable versioning for alias - max number of generated checks exeeded.");
+	}
+
+      VEC_truncate (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo), 0);
+
+      return false;
+    }
+  VEC_safe_push (ddr_p, heap, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo), ddr);
+  return true;
+}
+
 /* Function vect_analyze_data_ref_dependences.
           
    Examine all the data references in the loop, and make sure there do not
@@ -1133,7 +1202,7 @@
 vect_analyze_data_ref_dependences (loop_vec_info loop_vinfo)
 {
   unsigned int i;
-  VEC (ddr_p, heap) *ddrs = LOOP_VINFO_DDRS (loop_vinfo);
+  VEC (ddr_p, heap) * ddrs = LOOP_VINFO_DDRS (loop_vinfo);
   struct data_dependence_relation *ddr;
 
   if (vect_print_dump_info (REPORT_DETAILS)) 
@@ -1141,7 +1210,11 @@
      
   for (i = 0; VEC_iterate (ddr_p, ddrs, i, ddr); i++)
     if (vect_analyze_data_ref_dependence (ddr, loop_vinfo))
+      {
+	/* Add to list of ddrs that need to be tested at run-time.  */
+	if (!vect_mark_for_runtime_alias_test (ddr, loop_vinfo))
       return false;
+      }
 
   return true;
 }
@@ -1554,6 +1627,7 @@
   bool stat;
   tree stmt;
   stmt_vec_info stmt_info;
+  int vect_versioning_for_alias_required;
 
   if (vect_print_dump_info (REPORT_DETAILS))
     fprintf (vect_dump, "=== vect_enhance_data_refs_alignment ===");
@@ -1619,9 +1693,15 @@
 	}
     }
 
-  /* Often peeling for alignment will require peeling for loop-bound, which in 
-     turn requires that we know how to adjust the loop ivs after the loop.  */
-  if (!vect_can_advance_ivs_p (loop_vinfo)
+  vect_versioning_for_alias_required =
+    (VEC_length (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo)) > 0);
+
+  /* Temporarily, if versioning for alias is required, we disable peeling
+     until we support peeling and versioning.  Often peeling for alignment
+     will require peeling for loop-bound, which in turn requires that we
+     know how to adjust the loop ivs after the loop.  */
+  if (vect_versioning_for_alias_required
+       || !vect_can_advance_ivs_p (loop_vinfo)
       || !slpeel_can_duplicate_loop_p (loop, single_exit (loop)))
     do_peeling = false;
 
@@ -1749,7 +1829,7 @@
               if (known_alignment_for_access_p (dr)
                   || VEC_length (tree,
                                  LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo))
-                     >= (unsigned) PARAM_VALUE (PARAM_VECT_MAX_VERSION_CHECKS))
+                     >= (unsigned) PARAM_VALUE (PARAM_VECT_MAX_VERSION_FOR_ALIGNMENT_CHECKS))
                 {
                   do_versioning = false;
                   break;
Index: tree-vect-transform.c
===================================================================
--- tree-vect-transform.c	(revision 127316)
+++ tree-vect-transform.c	(working copy)
@@ -5805,7 +5805,111 @@
                  and_tmp_name, ptrsize_zero);
 }
 
+/* Function vect_create_cond_for_alias_checks.
 
+   Create a conditional expression that represents the run-time checks for
+   overlapping of adress ranges represented by a list of data references
+   relations passed as input.
+
+   Input:
+   COND_EXPR  - input conditional expression.  New conditions will be chained
+                logical and operation.
+   LOOP_VINFO - fields of the loop information are used.
+                LOOP_VINFO_MAY_ALIAS_STMTS contains the list of ddrs to be
+		checked.
+
+   Output:
+   COND_EXPR - conditional expression.
+   COND_EXPR_STMT_LIST - statements needed to construct the conditional
+                         expression.
+   The returned value is the conditional expression to be used in the if
+   statement that controls which version of the loop gets executed at runtime.
+*/
+
+static void
+vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo,
+				   tree * cond_expr,
+				   tree * cond_expr_stmt_list)
+{
+  VEC (ddr_p, heap) * may_alias_ddrs =
+    LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo);
+  tree vect_factor =
+    build_int_cst (integer_type_node, LOOP_VINFO_VECT_FACTOR (loop_vinfo));
+
+  ddr_p ddr;
+  unsigned int i;
+  tree part_cond_expr;
+
+  /* Create expression
+     ((store_ptr_0 + store_segment_length_0) < load_ptr_0)
+     || (load_ptr_0 + load_segment_length_0) < store_ptr_0))
+     &&         
+     ...
+     &&
+     ((store_ptr_n + store_segment_length_n) < load_ptr_n)
+     || (load_ptr_n + load_segment_length_n) < store_ptr_n))  */
+
+  if (VEC_empty (ddr_p, may_alias_ddrs))
+    return;
+
+  for (i = 0; VEC_iterate (ddr_p, may_alias_ddrs, i, ddr); i++)
+    {
+      tree stmt_a = DR_STMT (DDR_A (ddr));
+      tree stmt_b = DR_STMT (DDR_B (ddr));
+
+      tree addr_base_a;
+      tree addr_base_b;
+
+      tree step_a = DR_STEP (DDR_A (ddr));
+      tree segment_length_a =
+	fold_build2 (MULT_EXPR, integer_type_node, step_a, vect_factor);
+
+      tree step_b = DR_STEP (DDR_B (ddr));
+      tree segment_length_b =
+	fold_build2 (MULT_EXPR, integer_type_node, step_b, vect_factor);
+
+
+      if (vect_print_dump_info (REPORT_DR_DETAILS))
+	{
+	  fprintf (vect_dump,
+		   "create runtime check for data references ");
+	  print_generic_expr (vect_dump, DR_REF (DDR_A (ddr)), TDF_SLIM);
+	  fprintf (vect_dump, " and ");
+	  print_generic_expr (vect_dump, DR_REF (DDR_B (ddr)), TDF_SLIM);
+	}
+
+      addr_base_a =
+        vect_create_addr_base_for_vector_ref (stmt_a, cond_expr_stmt_list,
+					      NULL_TREE);
+      addr_base_b =
+        vect_create_addr_base_for_vector_ref (stmt_b, cond_expr_stmt_list,
+					      NULL_TREE);
+
+      part_cond_expr = 
+      	fold_build2 (TRUTH_OR_EXPR, boolean_type_node,
+	  fold_build2 (LT_EXPR, boolean_type_node,
+	    fold_build2 (PLUS_EXPR, ptr_type_node,
+	      addr_base_a,
+	      segment_length_a),
+	    addr_base_b),
+	  fold_build2 (LT_EXPR, boolean_type_node,
+	    fold_build2 (PLUS_EXPR, ptr_type_node,
+	      addr_base_b,
+	      segment_length_b),
+	    addr_base_a));
+      
+      if (*cond_expr)
+	*cond_expr = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
+			          *cond_expr, part_cond_expr);
+      else
+	*cond_expr = part_cond_expr;
+    }
+    if (vect_print_dump_info (REPORT_VECTORIZED_LOOPS))
+      fprintf (vect_dump, "created %u versioning for alias checks.\n",
+               VEC_length (ddr_p, may_alias_ddrs));
+
+}
+
 /* Function vect_transform_loop.
 
    The analysis phase has determined that the loop is vectorizable.
@@ -5827,16 +5931,21 @@
   if (vect_print_dump_info (REPORT_DETAILS))
     fprintf (vect_dump, "=== vec_transform_loop ===");
 
-  /* If the loop has data references that may or may not be aligned then
+  /* If the loop has data references that may or may not be aligned or/and
+     has data reference relations whose independence was not proven then
      two versions of the loop need to be generated, one which is vectorized
      and one which isn't.  A test is then generated to control which of the
      loops is executed.  The test checks for the alignment of all of the
-     data references that may or may not be aligned. */
+     data references that may or may not be aligned.  An additional
+     sequence of runtime tests is generated for each pairs of DDRs whose
+     independence was not proven.  The vectorised version of loop is 
+     executed only if both alias and alignment tests are passed.  */
 
-  if (VEC_length (tree, LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo)))
+  if (VEC_length (tree, LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo))
+      || VEC_length (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo)))
     {
       struct loop *nloop;
-      tree cond_expr;
+      tree cond_expr = NULL_TREE;
       tree cond_expr_stmt_list = NULL_TREE;
       basic_block condition_bb;
       block_stmt_iterator cond_exp_bsi;
@@ -5845,9 +5954,23 @@
       edge new_exit_e, e;
       tree orig_phi, new_phi, arg;
       unsigned prob = 4 * REG_BR_PROB_BASE / 5;
+      tree gimplify_stmt_list;
 
-      cond_expr = vect_create_cond_for_align_checks (loop_vinfo,
+      if (VEC_length (tree, LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo)))
+	cond_expr =
+	  vect_create_cond_for_align_checks (loop_vinfo, &cond_expr_stmt_list);
+
+      if (VEC_length (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo)))
+	vect_create_cond_for_alias_checks (loop_vinfo, &cond_expr,
                                                      &cond_expr_stmt_list);
+
+      cond_expr =
+        fold_build2 (NE_EXPR, boolean_type_node, cond_expr, integer_zero_node);
+      cond_expr =
+        force_gimple_operand (cond_expr, &gimplify_stmt_list, true,
+                              NULL_TREE);
+      append_to_statement_list (gimplify_stmt_list, &cond_expr_stmt_list);
+
       initialize_original_copy_tables ();
       nloop = loop_version (loop, cond_expr, &condition_bb,
 			    prob, prob, REG_BR_PROB_BASE - prob, true);
Index: params.def
===================================================================
--- params.def	(revision 127316)
+++ params.def	(working copy)
@@ -485,11 +485,16 @@
 	 "When set to 1, use expensive methods to eliminate all redundant constraints",
 	 0, 0, 1)
 
-DEFPARAM(PARAM_VECT_MAX_VERSION_CHECKS,
-         "vect-max-version-checks",
-         "Bound on number of runtime checks inserted by the vectorizer's loop versioning",
+DEFPARAM(PARAM_VECT_MAX_VERSION_FOR_ALIGNMENT_CHECKS,
+         "vect-max-version-for-alignment-checks",
+         "Bound on number of runtime checks inserted by the vectorizer's loop versioning for alignment check",
          6, 0, 0)
 
+DEFPARAM(PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS,
+         "vect-max-version-for-alias-checks",
+         "Bound on number of runtime checks inserted by the vectorizer's loop versioning for alias check",
+         10, 0, 0)
+
 DEFPARAM(PARAM_MAX_CSELIB_MEMORY_LOCATIONS,
 	 "max-cselib-memory-locations",
 	 "The maximum memory locations recorded by cselib",
Index: testsuite/gcc.dg/vect/no-vfa-vect-53.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-vect-53.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-vect-53.c	(revision 0)
@@ -0,0 +1,62 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (const float *pa, const float *pb, const float *pc) 
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != (pb[i] * pc[i]))
+	abort ();
+    }
+
+  return;
+}
+
+/* Unaligned pointer read accesses, aligned pointer write access.
+   The loop bound is unknown.
+   Can't prove that the pointers don't alias.
+   vect-49.c is similar to this one with one difference:
+        the loop bound is known.
+   vect-52.c is similar to this one with one difference:
+        aliasing is not a problem.  */
+
+int
+main1 (int n, float *pb, float *pc)
+{
+  float pa[N] __attribute__ ((__aligned__(16)));
+  int i;
+
+  for (i = 0; i < n; i++)
+    {
+      pa[i] = pb[i] * pc[i];
+    }
+
+  bar (pa,pb,pc);
+
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  float a[N] __attribute__ ((__aligned__(16)));
+  float b[N+1] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60};
+  float c[N+1] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
+
+  check_vect ();
+
+  main1 (N,&b[1],c);
+  main1 (N,&b[1],&c[1]);
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect-102a.c
===================================================================
--- testsuite/gcc.dg/vect/vect-102a.c	(revision 127316)
+++ testsuite/gcc.dg/vect/vect-102a.c	(working copy)
@@ -1,57 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 9
-
-struct extraction
-{
-  int a[N];
-  int b[N];
-};
-
-static int a[N] = {1,2,3,4,5,6,7,8,9};
-static int b[N] = {2,3,4,5,6,7,8,9,9};
-volatile int foo;
-
-int main1 (int x, int y) {
-  int i;
-  struct extraction *p;
-  p = (struct extraction *) malloc (sizeof (struct extraction));
-
-  for (i = 0; i < N; i++)
-    {
-       p->a[i] = a[i];
-       if (foo == 135)
-	 abort (); /* to avoid vectorization  */
-    }
-
-  /* Not vectorizable: distance 1.  */
-  for (i = 0; i < N - 1; i++)
-    {
-       p->a[x + i] = p->a[x + i + 1];
-    }
-
-  /* check results: */
-  for (i = 0; i < N; i++)
-    {
-       if (p->a[i] != b[i])
-         abort();
-    }
-  return 0;
-}
-
-int main (void)
-{ 
-  check_vect ();
-
-  foo = 0;
-  return main1 (0, N);
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
-/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
-
Index: testsuite/gcc.dg/vect/no-vfa-vect-45.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-vect-45.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-vect-45.c	(revision 0)
@@ -0,0 +1,59 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (const float *pa, const float *pb, const float *pc) 
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != (pb[i] * pc[i]))
+	abort ();
+    }
+
+  return;
+}
+
+/* Unaligned pointer accesses, with unknown alignment.
+   The loop bound is known and divisible by the vectorization factor.
+   Can't prove that the pointers don't alias.
+   vect-51.c is similar to this one with one difference:
+        the loop bound is unknown.
+   vect-44.c is similar to this one with one difference:
+        Aliasing is not a problem.  */
+
+int
+main1 (float *pa, float *pb, float *pc)
+{
+  int i;
+
+  for (i = 0; i < N; i++)
+    {
+      pa[i] = pb[i] * pc[i];
+    }
+
+  bar (pa,pb,pc);
+
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  float a[N];
+  float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
+  float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+
+  check_vect ();
+
+  main1 (a,b,c);
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/no-vfa-vect-37.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-vect-37.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-vect-37.c	(revision 0)
@@ -0,0 +1,61 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+char x[N] __attribute__ ((__aligned__(16)));
+ 
+int main1 (char *y)
+{  
+  struct {
+    char *p;
+    char *q;
+  } s;
+  char cb[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
+  int i;
+
+  /* Not vectorized - can't antialias the pointer s.p from the array cb.  */
+  s.p = y;
+  for (i = 0; i < N; i++)
+    {
+      s.p[i] = cb[i];
+    }
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (s.p[i] != cb[i])
+        abort ();
+    }
+
+  /* Not vectorized - can't antialias the pointer s.p from the pointer s.q.  */
+  s.q = cb;
+  for (i = 0; i < N; i++)
+    {
+      s.p[i] = s.q[i];
+    }
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (s.p[i] != s.q[i])
+        abort ();
+    }
+
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+  
+  return main1 (x);
+} 
+
+/* Currently the loops fail to vectorize due to aliasing problems.
+   If/when the aliasing problems are resolved, unalignment may
+   prevent vectorization on some targets.  */
+/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "can't determine dependence between" 2 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/no-vfa-vect-79.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-vect-79.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-vect-79.c	(revision 0)
@@ -0,0 +1,50 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+
+float fa[N] __attribute__ ((__aligned__(16)));
+float fb[N+4] __attribute__ ((__aligned__(16))) = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 7.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0};
+float fc[N] __attribute__ ((__aligned__(16))) = {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 7.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5};
+
+/* Like vect-80.c but the pointers are not annotated as restricted,
+   and therefore can't be antialiased.  */
+
+int
+main1 (float *pa, float *pb, float *pc)
+{
+  int i;
+  float *q = pb + 4;
+
+  for (i = 0; i < N; i++)
+    {
+      pa[i] = q[i] * pc[i];
+    }
+
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != q[i] * pc[i])
+	abort();
+    }
+  
+  return 0;
+}
+
+
+int main (void)
+{ 
+  check_vect ();
+
+  main1 (fa, fb, fc);
+
+  return 0;	
+}
+
+/* Currently the loops fail to vectorize due to aliasing problems.
+  If/when the aliasing problems are resolved, unalignment may
+  prevent vectorization on some targets.  */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "can't determine dependence between" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect-51.c
===================================================================
--- testsuite/gcc.dg/vect/vect-51.c	(revision 127316)
+++ testsuite/gcc.dg/vect/vect-51.c	(working copy)
@@ -1,59 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (const float *pa, const float *pb, const float *pc) 
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != (pb[i] * pc[i]))
-	abort ();
-    }
-
-  return;
-}
-
-/* Unaligned pointer accesses, with unknown alignment.
-   The loop bound is unknown.
-   Can't prove that the pointers don't alias.
-   vect-45.c is similar to this one with one difference:
-        the loop bound is known.
-   vect-50.c is similar to this one with one difference:
-        Aliasing is not a problem.  */
-
-int
-main1 (int n, float *pa, float *pb, float *pc)
-{
-  int i;
-
-  for (i = 0; i < n; i++)
-    {
-      pa[i] = pb[i] * pc[i];
-    }
-
-  bar (pa,pb,pc);
-
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  float a[N];
-  float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
-  float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-
-  check_vect ();
-
-  main1 (N,a,b,c);
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/pr29145.c
===================================================================
--- testsuite/gcc.dg/vect/pr29145.c	(revision 127316)
+++ testsuite/gcc.dg/vect/pr29145.c	(working copy)
@@ -1,48 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-void with_restrict(int * __restrict p)
-{
-  int i;
-  int *q = p - 2;
-
-  for (i = 0; i < 1000; ++i) {
-    p[i] = q[i];
-  }
-}
-
-void without_restrict(int * p)
-{
-  int i;
-  int *q = p - 2;
-
-  for (i = 0; i < 1000; ++i) {
-    p[i] = q[i];
-  }
-}
-
-int main(void)
-{
-  int i;
-  int a[1002];
-  int b[1002];
-
-  for (i = 0; i < 1002; ++i) {
-    a[i] = b[i] = i;
-  }
-
-  with_restrict(a + 2);
-  without_restrict(b + 2);
-
-  for (i = 0; i < 1002; ++i) {
-    if (a[i] != b[i])
-      abort();
-  }
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect"  } } */
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/no-vfa-vect-102a.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-vect-102a.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-vect-102a.c	(revision 0)
@@ -0,0 +1,57 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 9
+
+struct extraction
+{
+  int a[N];
+  int b[N];
+};
+
+static int a[N] = {1,2,3,4,5,6,7,8,9};
+static int b[N] = {2,3,4,5,6,7,8,9,9};
+volatile int foo;
+
+int main1 (int x, int y) {
+  int i;
+  struct extraction *p;
+  p = (struct extraction *) malloc (sizeof (struct extraction));
+
+  for (i = 0; i < N; i++)
+    {
+       p->a[i] = a[i];
+       if (foo == 135)
+	 abort (); /* to avoid vectorization  */
+    }
+
+  /* Not vectorizable: distance 1.  */
+  for (i = 0; i < N - 1; i++)
+    {
+       p->a[x + i] = p->a[x + i + 1];
+    }
+
+  /* check results: */
+  for (i = 0; i < N; i++)
+    {
+       if (p->a[i] != b[i])
+         abort();
+    }
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+
+  foo = 0;
+  return main1 (0, N);
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
+/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
Index: testsuite/gcc.dg/vect/vect-43.c
===================================================================
--- testsuite/gcc.dg/vect/vect-43.c	(revision 127316)
+++ testsuite/gcc.dg/vect/vect-43.c	(working copy)
@@ -1,78 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (float *pa, float *pb, float *pc) 
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != (pb[i] * pc[i]))
-	abort ();
-    }
-
-  return;
-}
-
-
-int
-main1 (float *pa)
-{
-  int i;
-  float pb[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
-  float pc[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-
- /* Not vectorizable: pa may alias pb and/or pc, since their addresses escape.  */
-  for (i = 0; i < N; i++)
-    {
-      pa[i] = pb[i] * pc[i];
-    }
-
-  bar (pa,pb,pc);
-
-  return 0;
-}
-
-int
-main2 (float * pa)
-{
-  int i;
-  float pb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
-  float pc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-
-  /* Vectorizable: pb and pc addresses do not escape.  */
-  for (i = 0; i < N; i++)
-    {
-      pa[i] = pb[i] * pc[i];
-    }   
-  
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != (pb[i] * pc[i]))
-        abort ();
-    }
-  
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  float a[N] __attribute__ ((__aligned__(16)));
-
-  check_vect ();
-
-  main1 (a);
-  main2 (a);
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
-/*  { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target vect_no_align } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/no-vfa-vect-101.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-vect-101.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-vect-101.c	(revision 0)
@@ -0,0 +1,49 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 9
+
+struct extraction
+{
+  int a[N];
+  int b[N];
+};
+
+static int a[N] = {1,2,3,4,5,6,7,8,9};
+static int b[N] = {2,3,4,5,6,7,8,9,0};
+
+int main1 (int x, int y) {
+  int i;
+  struct extraction *p;
+  p = (struct extraction *) malloc (sizeof (struct extraction));
+
+  /* Not vectorizable: different unknown offset.  */
+  for (i = 0; i < N; i++)
+    {
+      *((int *)p + x + i) = a[i];
+      *((int *)p + y + i) = b[i];
+    }
+
+  /* check results: */
+  for (i = 0; i < N; i++)
+    {
+       if (p->a[i] != a[i] || p->b[i] != b[i])
+         abort();
+    }
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+
+  return main1 (0, N);
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
+/* { dg-final { scan-tree-dump-times "can't determine dependence" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
Index: testsuite/gcc.dg/vect/vect-61.c
===================================================================
--- testsuite/gcc.dg/vect/vect-61.c	(revision 127316)
+++ testsuite/gcc.dg/vect/vect-61.c	(working copy)
@@ -1,64 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (float *pa, float *pb, float *pc)
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N/2; i++)
-    {
-      if (pa[i] != (pb[i+1] * pc[i+1]))
-	abort ();
-    }
-
-  return;
-}
-
-/* Unaligned pointer read accesses with known alignment,
-   and an unaligned write access with unknown alignment.
-   The loop bound is iunknown.
-   Can't prove that the pointers don't alias.
-   vect-57.c is similar to this one with one difference:
-        the loop bound is known.
-   vect-60.c is similar to this one with two differences:
-        aliasing is not a problem, and the write access is unaligned.  */
-
-int
-main1 (int n , float *pa)
-{
-  int i;
-  float b[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
-  float c[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-  float *pb = b;
-  float *pc = c;
-
-  for (i = 0; i < n/2; i++)
-    {
-      pa[i] = pb[i+1] * pc[i+1];
-    }
-
-  bar (pa,pb,pc);
-
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  int n=N;
-  float a[N] __attribute__ ((__aligned__(16)));
-
-  check_vect ();
-  main1 (n,a);
-
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect-53.c
===================================================================
--- testsuite/gcc.dg/vect/vect-53.c	(revision 127316)
+++ testsuite/gcc.dg/vect/vect-53.c	(working copy)
@@ -1,62 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (const float *pa, const float *pb, const float *pc) 
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != (pb[i] * pc[i]))
-	abort ();
-    }
-
-  return;
-}
-
-/* Unaligned pointer read accesses, aligned pointer write access.
-   The loop bound is unknown.
-   Can't prove that the pointers don't alias.
-   vect-49.c is similar to this one with one difference:
-        the loop bound is known.
-   vect-52.c is similar to this one with one difference:
-        aliasing is not a problem.  */
-
-int
-main1 (int n, float *pb, float *pc)
-{
-  float pa[N] __attribute__ ((__aligned__(16)));
-  int i;
-
-  for (i = 0; i < n; i++)
-    {
-      pa[i] = pb[i] * pc[i];
-    }
-
-  bar (pa,pb,pc);
-
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  float a[N] __attribute__ ((__aligned__(16)));
-  float b[N+1] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60};
-  float c[N+1] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
-
-  check_vect ();
-
-  main1 (N,&b[1],c);
-  main1 (N,&b[1],&c[1]);
-
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/no-vfa-vect-102.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-vect-102.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-vect-102.c	(revision 0)
@@ -0,0 +1,57 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 9
+
+struct extraction
+{
+  int a[N];
+  int b[N];
+};
+
+static int a[N] = {1,2,3,4,5,6,7,8,9};
+static int b[N] = {2,3,4,5,6,7,8,9,9};
+volatile int foo;
+
+int main1 (int x, int y) {
+  int i;
+  struct extraction *p;
+  p = (struct extraction *) malloc (sizeof (struct extraction));
+
+  for (i = 0; i < N; i++)
+    {
+       p->a[i] = a[i];
+       if (foo == 135)
+	 abort (); /* to avoid vectorization  */
+    }
+
+  /* Not vectorizable: distance 1.  */
+  for (i = 0; i < N - 1; i++)
+    {
+       *((int *)p + x + i) = *((int *)p + x + i + 1);
+    }
+
+  /* check results: */
+  for (i = 0; i < N; i++)
+    {
+       if (p->a[i] != b[i])
+         abort();
+    }
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+
+  foo = 0;
+  return main1 (0, N);
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
+/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
Index: testsuite/gcc.dg/vect/vect-45.c
===================================================================
--- testsuite/gcc.dg/vect/vect-45.c	(revision 127316)
+++ testsuite/gcc.dg/vect/vect-45.c	(working copy)
@@ -1,59 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (const float *pa, const float *pb, const float *pc) 
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != (pb[i] * pc[i]))
-	abort ();
-    }
-
-  return;
-}
-
-/* Unaligned pointer accesses, with unknown alignment.
-   The loop bound is known and divisible by the vectorization factor.
-   Can't prove that the pointers don't alias.
-   vect-51.c is similar to this one with one difference:
-        the loop bound is unknown.
-   vect-44.c is similar to this one with one difference:
-        Aliasing is not a problem.  */
-
-int
-main1 (float *pa, float *pb, float *pc)
-{
-  int i;
-
-  for (i = 0; i < N; i++)
-    {
-      pa[i] = pb[i] * pc[i];
-    }
-
-  bar (pa,pb,pc);
-
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  float a[N];
-  float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
-  float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-
-  check_vect ();
-
-  main1 (a,b,c);
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect-101.c
===================================================================
--- testsuite/gcc.dg/vect/vect-101.c	(revision 127316)
+++ testsuite/gcc.dg/vect/vect-101.c	(working copy)
@@ -1,49 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 9
-
-struct extraction
-{
-  int a[N];
-  int b[N];
-};
-
-static int a[N] = {1,2,3,4,5,6,7,8,9};
-static int b[N] = {2,3,4,5,6,7,8,9,0};
-
-int main1 (int x, int y) {
-  int i;
-  struct extraction *p;
-  p = (struct extraction *) malloc (sizeof (struct extraction));
-
-  /* Not vectorizable: different unknown offset.  */
-  for (i = 0; i < N; i++)
-    {
-      *((int *)p + x + i) = a[i];
-      *((int *)p + y + i) = b[i];
-    }
-
-  /* check results: */
-  for (i = 0; i < N; i++)
-    {
-       if (p->a[i] != a[i] || p->b[i] != b[i])
-         abort();
-    }
-  return 0;
-}
-
-int main (void)
-{ 
-  check_vect ();
-
-  return main1 (0, N);
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
-/* { dg-final { scan-tree-dump-times "can't determine dependence" 1 "vect" } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
-
Index: testsuite/gcc.dg/vect/no-vfa-vect-57.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-vect-57.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-vect-57.c	(revision 0)
@@ -0,0 +1,62 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (float *pa, float *pb, float *pc)
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N/2; i++)
+    {
+      if (pa[i] != (pb[i+1] * pc[i+1]))
+        abort ();
+    }
+
+  return;
+}
+
+/* Unaligned pointer read accesses with known alignment,
+   and an unaligned write access with unknown alignment.
+   The loop bound is known and divisible by the vectorization factor.
+   Can't prove that the pointers don't alias.
+   vect-61.c is similar to this one with one difference:
+        the loop bound is unknown.
+   vect-56.c is similar to this one with two differences:
+        aliasing is a problem, and the write access is aligned.  */
+
+int
+main1 (float *pa)
+{
+  int i;
+  float b[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
+  float c[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+  float *pb = b;
+  float *pc = c;
+
+  for (i = 0; i < N/2; i++)
+    {
+      pa[i] = pb[i+1] * pc[i+1];
+    }
+
+  bar (pa, pb, pc);
+
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  float a[N] __attribute__ ((__aligned__(16)));
+
+  check_vect ();
+  main1 (a);
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect-37.c
===================================================================
--- testsuite/gcc.dg/vect/vect-37.c	(revision 127316)
+++ testsuite/gcc.dg/vect/vect-37.c	(working copy)
@@ -1,61 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 16
-char x[N] __attribute__ ((__aligned__(16)));
- 
-int main1 (char *y)
-{  
-  struct {
-    char *p;
-    char *q;
-  } s;
-  char cb[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
-  int i;
-
-  /* Not vectorized - can't antialias the pointer s.p from the array cb.  */
-  s.p = y;
-  for (i = 0; i < N; i++)
-    {
-      s.p[i] = cb[i];
-    }
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (s.p[i] != cb[i])
-        abort ();
-    }
-
-  /* Not vectorized - can't antialias the pointer s.p from the pointer s.q.  */
-  s.q = cb;
-  for (i = 0; i < N; i++)
-    {
-      s.p[i] = s.q[i];
-    }
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (s.p[i] != s.q[i])
-        abort ();
-    }
-
-  return 0;
-}
-
-int main (void)
-{ 
-  check_vect ();
-  
-  return main1 (x);
-} 
-
-/* Currently the loops fail to vectorize due to aliasing problems.
-   If/when the aliasing problems are resolved, unalignment may
-   prevent vectorization on some targets.  */
-/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "can't determine dependence between" 2 "vect" } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect-79.c
===================================================================
--- testsuite/gcc.dg/vect/vect-79.c	(revision 127316)
+++ testsuite/gcc.dg/vect/vect-79.c	(working copy)
@@ -1,50 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 16
-
-float fa[N] __attribute__ ((__aligned__(16)));
-float fb[N+4] __attribute__ ((__aligned__(16))) = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 7.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0};
-float fc[N] __attribute__ ((__aligned__(16))) = {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 7.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5};
-
-/* Like vect-80.c but the pointers are not annotated as restricted,
-   and therefore can't be antialiased.  */
-
-int
-main1 (float *pa, float *pb, float *pc)
-{
-  int i;
-  float *q = pb + 4;
-
-  for (i = 0; i < N; i++)
-    {
-      pa[i] = q[i] * pc[i];
-    }
-
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != q[i] * pc[i])
-	abort();
-    }
-  
-  return 0;
-}
-
-
-int main (void)
-{ 
-  check_vect ();
-
-  main1 (fa, fb, fc);
-
-  return 0;	
-}
-
-/* Currently the loops fail to vectorize due to aliasing problems.
-  If/when the aliasing problems are resolved, unalignment may
-  prevent vectorization on some targets.  */
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "can't determine dependence between" 1 "vect" } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/no-vfa-vect-49.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-vect-49.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-vect-49.c	(revision 0)
@@ -0,0 +1,61 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (float *pa, float *pb, float *pc) 
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != (pb[i] * pc[i]))
+	abort ();
+    }
+
+  return;
+}
+
+/* Unaligned pointer read accesses, aligned pointer write access.
+   The loop bound is known and divisible by the vectorization factor.
+   Can't prove that the pointers don't alias.
+   vect-53.c is similar to this one with one difference:
+        the loop bound is unknown.
+   vect-48.c is similar to this one with one difference:
+        aliasing is not a problem.  */
+
+int
+main1 (float *pb, float *pc)
+{
+  float pa[N] __attribute__ ((__aligned__(16)));
+  int i;
+
+  for (i = 0; i < N; i++)
+    {
+      pa[i] = pb[i] * pc[i];
+    }
+
+  bar (pa,pb,pc);
+
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  float b[N+1] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60};
+  float c[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+
+  check_vect ();
+
+  main1 (b,c);
+  main1 (&b[1],c);
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect-102.c
===================================================================
--- testsuite/gcc.dg/vect/vect-102.c	(revision 127316)
+++ testsuite/gcc.dg/vect/vect-102.c	(working copy)
@@ -1,57 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 9
-
-struct extraction
-{
-  int a[N];
-  int b[N];
-};
-
-static int a[N] = {1,2,3,4,5,6,7,8,9};
-static int b[N] = {2,3,4,5,6,7,8,9,9};
-volatile int foo;
-
-int main1 (int x, int y) {
-  int i;
-  struct extraction *p;
-  p = (struct extraction *) malloc (sizeof (struct extraction));
-
-  for (i = 0; i < N; i++)
-    {
-       p->a[i] = a[i];
-       if (foo == 135)
-	 abort (); /* to avoid vectorization  */
-    }
-
-  /* Not vectorizable: distance 1.  */
-  for (i = 0; i < N - 1; i++)
-    {
-       *((int *)p + x + i) = *((int *)p + x + i + 1);
-    }
-
-  /* check results: */
-  for (i = 0; i < N; i++)
-    {
-       if (p->a[i] != b[i])
-         abort();
-    }
-  return 0;
-}
-
-int main (void)
-{ 
-  check_vect ();
-
-  foo = 0;
-  return main1 (0, N);
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
-/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
-
Index: testsuite/gcc.dg/vect/no-vfa-vect-51.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-vect-51.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-vect-51.c	(revision 0)
@@ -0,0 +1,59 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (const float *pa, const float *pb, const float *pc) 
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != (pb[i] * pc[i]))
+	abort ();
+    }
+
+  return;
+}
+
+/* Unaligned pointer accesses, with unknown alignment.
+   The loop bound is unknown.
+   Can't prove that the pointers don't alias.
+   vect-45.c is similar to this one with one difference:
+        the loop bound is known.
+   vect-50.c is similar to this one with one difference:
+        Aliasing is not a problem.  */
+
+int
+main1 (int n, float *pa, float *pb, float *pc)
+{
+  int i;
+
+  for (i = 0; i < n; i++)
+    {
+      pa[i] = pb[i] * pc[i];
+    }
+
+  bar (pa,pb,pc);
+
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  float a[N];
+  float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
+  float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+
+  check_vect ();
+
+  main1 (N,a,b,c);
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/no-vfa-pr29145.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-pr29145.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-pr29145.c	(revision 0)
@@ -0,0 +1,48 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+void with_restrict(int * __restrict p)
+{
+  int i;
+  int *q = p - 2;
+
+  for (i = 0; i < 1000; ++i) {
+    p[i] = q[i];
+  }
+}
+
+void without_restrict(int * p)
+{
+  int i;
+  int *q = p - 2;
+
+  for (i = 0; i < 1000; ++i) {
+    p[i] = q[i];
+  }
+}
+
+int main(void)
+{
+  int i;
+  int a[1002];
+  int b[1002];
+
+  for (i = 0; i < 1002; ++i) {
+    a[i] = b[i] = i;
+  }
+
+  with_restrict(a + 2);
+  without_restrict(b + 2);
+
+  for (i = 0; i < 1002; ++i) {
+    if (a[i] != b[i])
+      abort();
+  }
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect"  } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect-dv-2.c
===================================================================
--- testsuite/gcc.dg/vect/vect-dv-2.c	(revision 127316)
+++ testsuite/gcc.dg/vect/vect-dv-2.c	(working copy)
@@ -1,77 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-
-#include <stdarg.h>
-#include <signal.h>
-#include "tree-vect.h"
-
-#define N 64
-#define MAX 42
-
-extern void abort(void); 
-
-int main ()
-{  
-  int A[N];
-  int B[N];
-  int C[N];
-  int D[N];
-
-  int i, j;
-
-  check_vect ();
-
-  for (i = 0; i < N; i++)
-    {
-      A[i] = i;
-      B[i] = i;
-      C[i] = i;
-      D[i] = i;
-    }
-
-  /* Vectorizable */
-  for (i = 0; i < N-20; i++)
-    {
-      A[i] = A[i+20];
-    }
-
-  /* check results:  */
-  for (i = 0; i < N-20; i++)
-    {
-      if (A[i] != D[i+20])
-	abort ();
-    }
-
-  /* Vectorizable */
-  for (i = 0; i < 16; i++)
-    {
-      B[i] = B[i] + 5;
-    }
-
-  /* check results:  */
-  for (i = 0; i < 16; i++)
-    {
-      if (B[i] != C[i] + 5)
-	abort ();
-    }
-
-  /* Not vectorizable */
-  for (i = 0; i < 4; i++)
-    {
-      C[i] = C[i+3];
-    }
-
-  /* check results:  */
-  for (i = 0; i < 4; i++)
-    {
-      if (C[i] != D[i+3])
-	abort ();
-    }
-
-  return 0;
-}
-
-
-/* The initialization induction loop (with aligned access) is also vectorized.  */
-/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */
-/* { dg-final { scan-tree-dump-times "accesses have the same alignment." 2 "vect" } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/no-vfa-vect-43.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-vect-43.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-vect-43.c	(revision 0)
@@ -0,0 +1,78 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (float *pa, float *pb, float *pc) 
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != (pb[i] * pc[i]))
+	abort ();
+    }
+
+  return;
+}
+
+
+int
+main1 (float *pa)
+{
+  int i;
+  float pb[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
+  float pc[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+
+ /* Not vectorizable: pa may alias pb and/or pc, since their addresses escape.  */
+  for (i = 0; i < N; i++)
+    {
+      pa[i] = pb[i] * pc[i];
+    }
+
+  bar (pa,pb,pc);
+
+  return 0;
+}
+
+int
+main2 (float * pa)
+{
+  int i;
+  float pb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
+  float pc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+
+  /* Vectorizable: pb and pc addresses do not escape.  */
+  for (i = 0; i < N; i++)
+    {
+      pa[i] = pb[i] * pc[i];
+    }   
+  
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != (pb[i] * pc[i]))
+        abort ();
+    }
+  
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  float a[N] __attribute__ ((__aligned__(16)));
+
+  check_vect ();
+
+  main1 (a);
+  main2 (a);
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/*  { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target vect_no_align } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect-57.c
===================================================================
--- testsuite/gcc.dg/vect/vect-57.c	(revision 127316)
+++ testsuite/gcc.dg/vect/vect-57.c	(working copy)
@@ -1,62 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (float *pa, float *pb, float *pc)
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N/2; i++)
-    {
-      if (pa[i] != (pb[i+1] * pc[i+1]))
-        abort ();
-    }
-
-  return;
-}
-
-/* Unaligned pointer read accesses with known alignment,
-   and an unaligned write access with unknown alignment.
-   The loop bound is known and divisible by the vectorization factor.
-   Can't prove that the pointers don't alias.
-   vect-61.c is similar to this one with one difference:
-        the loop bound is unknown.
-   vect-56.c is similar to this one with two differences:
-        aliasing is a problem, and the write access is aligned.  */
-
-int
-main1 (float *pa)
-{
-  int i;
-  float b[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
-  float c[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-  float *pb = b;
-  float *pc = c;
-
-  for (i = 0; i < N/2; i++)
-    {
-      pa[i] = pb[i+1] * pc[i+1];
-    }
-
-  bar (pa, pb, pc);
-
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  float a[N] __attribute__ ((__aligned__(16)));
-
-  check_vect ();
-  main1 (a);
-
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/no-vfa-vect-dv-2.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-vect-dv-2.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-vect-dv-2.c	(revision 0)
@@ -0,0 +1,77 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include <signal.h>
+#include "tree-vect.h"
+
+#define N 64
+#define MAX 42
+
+extern void abort(void); 
+
+int main ()
+{  
+  int A[N];
+  int B[N];
+  int C[N];
+  int D[N];
+
+  int i, j;
+
+  check_vect ();
+
+  for (i = 0; i < N; i++)
+    {
+      A[i] = i;
+      B[i] = i;
+      C[i] = i;
+      D[i] = i;
+    }
+
+  /* Vectorizable */
+  for (i = 0; i < N-20; i++)
+    {
+      A[i] = A[i+20];
+    }
+
+  /* check results:  */
+  for (i = 0; i < N-20; i++)
+    {
+      if (A[i] != D[i+20])
+	abort ();
+    }
+
+  /* Vectorizable */
+  for (i = 0; i < 16; i++)
+    {
+      B[i] = B[i] + 5;
+    }
+
+  /* check results:  */
+  for (i = 0; i < 16; i++)
+    {
+      if (B[i] != C[i] + 5)
+	abort ();
+    }
+
+  /* Not vectorizable */
+  for (i = 0; i < 4; i++)
+    {
+      C[i] = C[i+3];
+    }
+
+  /* check results:  */
+  for (i = 0; i < 4; i++)
+    {
+      if (C[i] != D[i+3])
+	abort ();
+    }
+
+  return 0;
+}
+
+
+/* The initialization induction loop (with aligned access) is also vectorized.  */
+/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "accesses have the same alignment." 2 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/no-vfa-vect-61.c
===================================================================
--- testsuite/gcc.dg/vect/no-vfa-vect-61.c	(revision 0)
+++ testsuite/gcc.dg/vect/no-vfa-vect-61.c	(revision 0)
@@ -0,0 +1,64 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (float *pa, float *pb, float *pc)
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N/2; i++)
+    {
+      if (pa[i] != (pb[i+1] * pc[i+1]))
+	abort ();
+    }
+
+  return;
+}
+
+/* Unaligned pointer read accesses with known alignment,
+   and an unaligned write access with unknown alignment.
+   The loop bound is iunknown.
+   Can't prove that the pointers don't alias.
+   vect-57.c is similar to this one with one difference:
+        the loop bound is known.
+   vect-60.c is similar to this one with two differences:
+        aliasing is not a problem, and the write access is unaligned.  */
+
+int
+main1 (int n , float *pa)
+{
+  int i;
+  float b[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
+  float c[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+  float *pb = b;
+  float *pc = c;
+
+  for (i = 0; i < n/2; i++)
+    {
+      pa[i] = pb[i+1] * pc[i+1];
+    }
+
+  bar (pa,pb,pc);
+
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  int n=N;
+  float a[N] __attribute__ ((__aligned__(16)));
+
+  check_vect ();
+  main1 (n,a);
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/vect-49.c
===================================================================
--- testsuite/gcc.dg/vect/vect-49.c	(revision 127316)
+++ testsuite/gcc.dg/vect/vect-49.c	(working copy)
@@ -1,61 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (float *pa, float *pb, float *pc) 
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != (pb[i] * pc[i]))
-	abort ();
-    }
-
-  return;
-}
-
-/* Unaligned pointer read accesses, aligned pointer write access.
-   The loop bound is known and divisible by the vectorization factor.
-   Can't prove that the pointers don't alias.
-   vect-53.c is similar to this one with one difference:
-        the loop bound is unknown.
-   vect-48.c is similar to this one with one difference:
-        aliasing is not a problem.  */
-
-int
-main1 (float *pb, float *pc)
-{
-  float pa[N] __attribute__ ((__aligned__(16)));
-  int i;
-
-  for (i = 0; i < N; i++)
-    {
-      pa[i] = pb[i] * pc[i];
-    }
-
-  bar (pa,pb,pc);
-
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  float b[N+1] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60};
-  float c[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-
-  check_vect ();
-
-  main1 (b,c);
-  main1 (&b[1],c);
-
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gfortran.dg/vect/pr19049.f90
===================================================================
--- testsuite/gfortran.dg/vect/pr19049.f90	(revision 127316)
+++ testsuite/gfortran.dg/vect/pr19049.f90	(working copy)
@@ -1,24 +0,0 @@
-! { dg-do compile }
-! { dg-require-effective-target vect_float }
-
-subroutine s111 (ntimes,ld,n,ctime,dtime,a,b,c,d,e,aa,bb,cc) 
-!     linear dependence testing
-!     no dependence - vectorizable
-!     but not consecutive access
-
-      integer ntimes, ld, n, i, nl
-      real a(n), b(n), c(n), d(n), e(n), aa(ld,n), bb(ld,n), cc(ld,n)
-      real t1, t2, second, chksum, ctime, dtime, cs1d
-      do 1 nl = 1,2*ntimes
-      do 10 i = 2,n,2
-         a(i) = a(i-1) + b(i)
-  10  continue
-      call dummy(ld,n,a,b,c,d,e,aa,bb,cc,1.)
-  1   continue
-      return
-      end
-
-! { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } }
-! { dg-final { scan-tree-dump-times "complicated access pattern" 1 "vect" } }
-! { dg-final { cleanup-tree-dump "vect" } }
-
Index: testsuite/gfortran.dg/vect/no-vfa-pr19049.f90
===================================================================
--- testsuite/gfortran.dg/vect/no-vfa-pr19049.f90	(revision 0)
+++ testsuite/gfortran.dg/vect/no-vfa-pr19049.f90	(revision 0)
@@ -0,0 +1,24 @@
+! { dg-do compile }
+! { dg-require-effective-target vect_float }
+
+subroutine s111 (ntimes,ld,n,ctime,dtime,a,b,c,d,e,aa,bb,cc) 
+!     linear dependence testing
+!     no dependence - vectorizable
+!     but not consecutive access
+
+      integer ntimes, ld, n, i, nl
+      real a(n), b(n), c(n), d(n), e(n), aa(ld,n), bb(ld,n), cc(ld,n)
+      real t1, t2, second, chksum, ctime, dtime, cs1d
+      do 1 nl = 1,2*ntimes
+      do 10 i = 2,n,2
+         a(i) = a(i-1) + b(i)
+  10  continue
+      call dummy(ld,n,a,b,c,d,e,aa,bb,cc,1.)
+  1   continue
+      return
+      end
+
+! { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } }
+! { dg-final { scan-tree-dump-times "complicated access pattern" 1 "vect" } }
+! { dg-final { cleanup-tree-dump "vect" } }
+

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [4.3 projects] Verctorizer - versioning for alias
  2007-08-14 11:02 [PATCH] [4.3 projects] Verctorizer - versioning for alias Victor Kaplansky
@ 2007-08-14 11:38 ` Zdenek Dvorak
  2007-08-14 12:23   ` Victor Kaplansky
  2007-08-14 17:07 ` Dorit Nuzman
  1 sibling, 1 reply; 10+ messages in thread
From: Zdenek Dvorak @ 2007-08-14 11:38 UTC (permalink / raw)
  To: Victor Kaplansky; +Cc: gcc-patches

Hello,

>             * gcc.dg/vect/vect-vfa-01.c: New.
>             * gcc.dg/vect/vect-vfa-02.c: New.
>             * gcc.dg/vect/vect-vfa-03.c: New.


> (See attached file: vfa.txt)
> Index: testsuite/gcc.dg/vect/vect-vfa-01.c
> ===================================================================
> --- testsuite/gcc.dg/vect/vect-vfa-01.c	(revision 0)
> +++ testsuite/gcc.dg/vect/vect-vfa-01.c	(revision 0)
> @@ -0,0 +1,39 @@
> +/* { dg-require-effective-target vect_int } */
> +
> +#include <stdarg.h>
> +#include "tree-vect.h"
> +
> +#define N 16
> +int result[N] = {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27};
> +int X[N] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25};
> +int Y[N] = {};
> + 
> +void
> +foo (int *in, int *out)
> +{  
> +  int i;
> +  
> +  for (i = 0; i < N; i++)
> +    out[i] = in[i] + 2;
> +}
> +
> +int
> +main (void)
> +{ 
> +  int i;
> +
> +  check_vect ();
> +
> +  foo (X, Y);

could you also add some test that checks the situation where the IN and
OUT pointers overlap in such a way that the vectorized copy of the loop
would produce wrong results (if it were used)?

> +/* Return TRUE if DDR_NEW is already found in MAY_ALIAS_DDRS list.  */
> +static bool
> +vect_is_duplicate_ddr (VEC (ddr_p, heap) * may_alias_ddrs, ddr_p ddr_new)

There should be an empty line between the comment and the function.

> +/* Function vect_create_cond_for_alias_checks.
>  
> +   Create a conditional expression that represents the run-time checks for
> +   overlapping of adress ranges represented by a list of data references
> +   relations passed as input.
> +
> +   Input:
> +   COND_EXPR  - input conditional expression.  New conditions will be chained
> +                logical and operation.

                   ^ with

> +   LOOP_VINFO - fields of the loop information are used.

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I am not
		   sure what this sentence is supposed to mean.

> +      part_cond_expr = 
> +      	fold_build2 (TRUTH_OR_EXPR, boolean_type_node,
> +	  fold_build2 (LT_EXPR, boolean_type_node,
> +	    fold_build2 (PLUS_EXPR, ptr_type_node,

                         ^^^^^^^^^
should be POINTER_PLUS_EXPR.  It is a bit suspicious that this passes
testing, as it should ICE in build2.  Can you check why it does not?

> +	      addr_base_a,
> +	      segment_length_a),
> +	    addr_base_b),
> +	  fold_build2 (LT_EXPR, boolean_type_node,
> +	    fold_build2 (PLUS_EXPR, ptr_type_node,

Ditto.

> Index: params.def
> ===================================================================
> --- params.def	(revision 127316)
> +++ params.def	(working copy)
> @@ -485,11 +485,16 @@
>  	 "When set to 1, use expensive methods to eliminate all redundant constraints",
>  	 0, 0, 1)
>  
> -DEFPARAM(PARAM_VECT_MAX_VERSION_CHECKS,
> -         "vect-max-version-checks",
> -         "Bound on number of runtime checks inserted by the vectorizer's loop versioning",
> +DEFPARAM(PARAM_VECT_MAX_VERSION_FOR_ALIGNMENT_CHECKS,
> +         "vect-max-version-for-alignment-checks",
> +         "Bound on number of runtime checks inserted by the vectorizer's loop versioning for alignment check",
>           6, 0, 0)
>  
> +DEFPARAM(PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS,
> +         "vect-max-version-for-alias-checks",
> +         "Bound on number of runtime checks inserted by the vectorizer's loop versioning for alias check",
> +         10, 0, 0)
> +

The params should be documented in invoke.texi.  Otherwise, the patch is
OK.

Zdenek

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [4.3 projects] Verctorizer - versioning for alias
  2007-08-14 11:38 ` Zdenek Dvorak
@ 2007-08-14 12:23   ` Victor Kaplansky
  0 siblings, 0 replies; 10+ messages in thread
From: Victor Kaplansky @ 2007-08-14 12:23 UTC (permalink / raw)
  To: Zdenek Dvorak; +Cc: gcc-patches



Zdenek Dvorak <rakdver@kam.mff.cuni.cz> wrote on 14/08/2007 02:37:27 PM:

>
> could you also add some test that checks the situation where the IN and
> OUT pointers overlap in such a way that the vectorized copy of the loop
> would produce wrong results (if it were used)?

OK, I'll add some.

>
> There should be an empty line between the comment and the function.
>

OK.

> > +                logical and operation.
>
>                    ^ with
>
> > +   LOOP_VINFO - fields of the loop information are used.
>
>                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I am not
>          sure what this sentence is supposed to mean.

I'll fix this.

>
> > +      part_cond_expr =
> > +         fold_build2 (TRUTH_OR_EXPR, boolean_type_node,
> > +     fold_build2 (LT_EXPR, boolean_type_node,
> > +       fold_build2 (PLUS_EXPR, ptr_type_node,
>
>                          ^^^^^^^^^
> should be POINTER_PLUS_EXPR.  It is a bit suspicious that this passes
> testing, as it should ICE in build2.  Can you check why it does not?

Interesting indeed. I'll try to step thru build2 to see why it doesn't ICE.
Anyway, I'll replace PLUS_EXPR by POINTER_PLUS_EXPR.

> The params should be documented in invoke.texi.
OK, I'll ad the docimentation.

 Otherwise, the patch is
> OK.
>
> Zdenek

Thanks, I'll resend fixed patch shortly.
-- Victor

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [4.3 projects] Verctorizer - versioning for alias
  2007-08-14 11:02 [PATCH] [4.3 projects] Verctorizer - versioning for alias Victor Kaplansky
  2007-08-14 11:38 ` Zdenek Dvorak
@ 2007-08-14 17:07 ` Dorit Nuzman
  1 sibling, 0 replies; 10+ messages in thread
From: Dorit Nuzman @ 2007-08-14 17:07 UTC (permalink / raw)
  To: Victor Kaplansky; +Cc: gcc-patches

>
> Often it is impossible to alias analysis to prove dependency or
> independency.  In such cases vectorizer is bound to be conservative.
> However in many cases at run-time we can validate the independence
> by testing that data reference ranges are not overlapped.
>
> This patch enhances the vectorizer by introducing run-time checks
> and loop versioning to take advantage of vectorized loop in case when
> data reference independence can be proved at run-time.  The number
> of added data reference test can be controlled by
> "vect-max-version-for-alias-checks" parameter.  The value of 0 will
> disable the versioning for alias.  Then maximum number of checks
> produced for versioning for alignment can now be controlled by
> "vect-max-version-for-alignment-checks".
>

Thanks Victor.

One thing that's missing is to update the cost-model evaluation for the
case that versioning for aliasing is applied. I don't mind if this comes as
a separate patch.

Another question I have is about reducing checks when you have a group of
interleaved accesses: I think we discussed in the past that it should be
enough to have one test per group that compares the "FIRST_DR" of the
group, as the representative of the whole group (using an appropriate
"segment_length"), instead of generating a test for each of the group
members. I'm not sure that this is what this patch does? (i.e., how many
checks will this patch generate if we have an interleaved group of size 4
that we read from and an interleaved group of size 4 that we write to?
there should be a check for only one pair of drs).

The other thing that I'm not sure we're careful enough about is
misalignment - if the datarefs in question are also unaligned, then if we
use explicit realignment - where we combine the data for each iteration
from two consecutive vectors in memory - in that case the aliasing range
should be what you currently compute + VF. (I think our static dependence
tester has the same problem... :-( )

Additional minor comments below.

> Bootstrapped and regtested on ppc64 and x86_64.
> Bootstrapped with vectorization enabled on x86_64.
> Okay for mainline?
>
> 2007-08-14  Victor Kaplansky <victork@il.ibm.com>
>
> ChangeLog:
>
>              * tree-vectorizer.c (new_loop_vec_info): Initialize new
>              field.
>              (destroy_loop_vec_info): Add call to VEC_free.
>              * tree-vectorizer.h (may_alias_ddrs): Define.
>              (LOOP_VINFO_MAY_ALIAS_DDRS): Define.
>              * tree-vect-analyze.c (vect_analyze_data_ref_dependence):
>              Change reporting to dump.
>              (vect_is_duplicate_ddr): New.
>              (vect_mark_for_runtime_alias_test): New.
>              (vect_analyze_data_ref_dependences) Add call to
>              vect_mark_for_runtime_alias_test.
>              (vect_enhance_data_refs_alignment): Define local variable
>              vect_versioning_for_alias_required, don't perform
>              versioning for alignment if versioning for alias is
>              required.

you mean "don't perform *peeling* for alignment if versioning for alias is
required", right?

>              (vect_enhance_data_refs_alignment): Use
>              PARAM_VECT_MAX_VERSION_FOR_ALIGNMENT_CHECKS instead of
>              PARAM_VECT_MAX_VERSION_CHECKS.
>              * tree-vect-transform.c (vect_create_cond_for_alias_checks):
>              New.
>              (vect_transform_loop): Add call to
>              vect_create_cond_for_alias_checks.
>              * params.def (PARAM_VECT_MAX_VERSION_FOR_ALIGNMENT_CHECKS):
>              Rename.
>              (PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS): Define.
>
> testsuite/ChangeLog:
>
>             * gcc.dg/vect/vect-vfa-01.c: New.
>             * gcc.dg/vect/vect-vfa-02.c: New.
>             * gcc.dg/vect/vect-vfa-03.c: New.
>             * gcc.dg/vect/vect-102a.c, gcc.dg/vect/vect-51.c,
>             gcc.dg/vect/pr29145.c, gcc.dg/vect/vect-43.c,
>             gcc.dg/vect/vect-61.c, gcc.dg/vect/vect-53.c,
>             gcc.dg/vect/vect-45.c, gcc.dg/vect/vect-101.c,
>             gcc.dg/vect/vect-37.c, gcc.dg/vect/vect-79.c,
>             gcc.dg/vect/vect-102.c, gcc.dg/vect/vect-dv-2.c,
>             gcc.dg/vect/vect-57.c, gcc.dg/vect/vect-49.c,
>             gfortran.dg/vect/pr19049.f90: Rename to start with
>             prefix no-vfa-.

Is there any testcase that combines data interleaving (strided access) with
versioning for aliasing?

>             * gcc.dg/vect/vect.exp: Disable versioning for alias
>             when test starts with no-vfa-.
>             * gfortran.dg/vect/vect.exp: Likewise.
>

> Index: tree-vect-analyze.c
> ===================================================================
> --- tree-vect-analyze.c     (revision 127316)
> +++ tree-vect-analyze.c     (working copy)
> @@ -1039,10 +1039,10 @@
>
>    if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know)
>      {
> -      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
> +      if (vect_print_dump_info (REPORT_DR_DETAILS))

I think that using REPORT_DR_DETAILS (which we should be using for
reporting data-ref and data-ref-dependence related stuff) is more
appropriate than REPORT_DR_DETAILS.

>          {
>            fprintf (vect_dump,
> -                   "not vectorized: can't determine dependence between
");
> +                   "versioning for alias required: can't determine
dependence between ");
>            print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
>            fprintf (vect_dump, " and ");
>            print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
> @@ -1052,9 +1052,9 @@
>
>    if (DDR_NUM_DIST_VECTS (ddr) == 0)
>      {
> -      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
> +      if (vect_print_dump_info (REPORT_DR_DETAILS))

Likewise

>          {
> -          fprintf (vect_dump, "not vectorized: bad dist vector for ");
> +          fprintf (vect_dump, "versioning for alias required: bad dist
vector for ");
>            print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
>            fprintf (vect_dump, " and ");
>            print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
> @@ -1108,10 +1108,10 @@
>       continue;
>     }
>
> -      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
> +      if (vect_print_dump_info (REPORT_DR_DETAILS))

Likewise

> +/* Return TRUE if DDR_NEW is already found in MAY_ALIAS_DDRS list.  */
> +static bool
> +vect_is_duplicate_ddr (VEC (ddr_p, heap) * may_alias_ddrs, ddr_p
ddr_new)
> +{

This reminds me that I'm not sure we make any attempt to prune the
may_misalign list (not even by consulting the SAME_ALIGN field). Just
something to add to the todo list...

> +/* Save DDR in LOOP_VINFO list of ddrs that may alias and need to be
> +   tested at run-time.  Returns false if number of run-time checks
> +   iserted by vectorizer is greater than maximum defined by

typo - inserted.

> +      if (vect_print_dump_info (REPORT_DR_DETAILS))
> +   {
> +     fprintf (vect_dump,
> +            "disable versioning for alias - max number of generated
checks exeeded.");
> +   }

typo - exceeded.
Also I think you also exceed 80-columns here... There are other occurences
of 80-column overflow.

> +   Create a conditional expression that represents the run-time checks
for
> +   overlapping of adress ranges represented by a list of data references

typo - address

> +     data references that may or may not be aligned.  An additional
> +     sequence of runtime tests is generated for each pairs of DDRs whose
> +     independence was not proven.  The vectorised version of loop is

vectorized

Also, maybe it's appropriate to factor out the versioning related stuff
from vect_transform_loop.

thanks,
dorit

> (See attached file: vfa.txt)[attachment "vfa.txt" deleted by Dorit
> Nuzman/Haifa/IBM]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [4.3 projects] Verctorizer - versioning for alias
       [not found] <OFD8F5F2C8.37DFE3DF-ONC2257339.004A59E3-C2257339.004BD2B1@LocalDomain>
  2007-08-18  7:54 ` Dorit Nuzman
  2007-08-19  9:20 ` Dorit Nuzman
@ 2007-08-19 15:13 ` Dorit Nuzman
  2 siblings, 0 replies; 10+ messages in thread
From: Dorit Nuzman @ 2007-08-19 15:13 UTC (permalink / raw)
  To: Victor Kaplansky; +Cc: gcc-patches, rakdver

Victor Kaplansky/Haifa/IBM wrote on 16/08/2007 16:48:11:

> Dorit Nuzman/Haifa/IBM wrote on 16/08/2007 04:11:46 PM:
> >
...
>
> >
> > So you're going to address the rest of the comments in a separate
> > patch (cost-model updates, improved handling of interleaved-
> > accesses, adding testcases that combine interleaving and versioning-
> > for-aliasing, factoring out the versioning related stuff from
> > vect_transform_loop)? (that would be fine with me, just want to make
> > sure you're planning to address these issues too).
>
> Yes, sure. Just forgot to mention that I'm planing to submit an
> additional patch with performance and other imrovments to versioning for
> alias and above issued will be addressed there.
>

Victor, I just noticed another thing: it looks like the
versioning-for-aliasing is called even when we know that the dependence
distance between the two memory accesses is less than VF (in which case
there is a dependence for sure and there's no point in checking that at
runtime). This should be avoided.

thanks,
dorit

> > so I asked this before: I think you mean "don't perform **peeling**
> > for alignment if versioning for alias is required", right?
>
> Sorry, I'll fix this in the Changelog.
>
> > I think you can use TYPE_VECTOR_SUBPARTS() instead of
> > GET_MODE_SIZE (TYPE_MODE ()) (just a tiny bit more compact)
>
> I think that it slightly different.  For example TYPE_VECTOR_SUBPARTS()
> returns 4 for a vector of integers on ppc, while
> GET_MODE_SIZE (TYPE_MODE ()) returns 16 - size of vector in bytes.
>
> >
> > Also, for more compact code, you could compute the vf*step once and
> > reuse it for both then and else. For your consideration.
> >
> > +     (vinfo_for_stmt (DR_STMT (dr))))));
> > +
> > +      segment_length =
> > + fold_convert (sizetype,
> > +   fold_build2 (PLUS_EXPR, integer_type_node,
> > +     fold_build2 (MULT_EXPR, integer_type_node, DR_STEP (dr),
> > +    vect_factor),
> > +     vector_size));
> > +
> > +
> > +    }
> > +  else
> > +    {
> > +      segment_length =
> > + fold_convert (sizetype,
> > +   fold_build2 (MULT_EXPR, integer_type_node, DR_STEP (dr),
> > +         vect_factor));
> > +    }
> > +
> > +    return segment_length;
> > +}
>
> OK, I'll address this in next patch.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [4.3 projects] Verctorizer - versioning for alias
       [not found] <OFD8F5F2C8.37DFE3DF-ONC2257339.004A59E3-C2257339.004BD2B1@LocalDomain>
  2007-08-18  7:54 ` Dorit Nuzman
@ 2007-08-19  9:20 ` Dorit Nuzman
  2007-08-19 15:13 ` Dorit Nuzman
  2 siblings, 0 replies; 10+ messages in thread
From: Dorit Nuzman @ 2007-08-19  9:20 UTC (permalink / raw)
  To: Victor Kaplansky; +Cc: gcc-patches, rakdver

Victor Kaplansky/Haifa/IBM wrote on 16/08/2007 16:48:11:

> Dorit Nuzman/Haifa/IBM wrote on 16/08/2007 04:11:46 PM:
> >
> > Is there a testcase that catches this case?
>
> vect-vfa-01.c catches it.
>
> >
> > >   - POINTER_PLUS_EXPR used insted of PLUS_EXPR for pointer
> > > arithmentics.
> > >   - Parameters "vect-max-version-for-alignment-checks" and
> > > "vect-max-version-for-alias-checks" documented in invoke.texi.
> >

I just realized that there's no check for optimize_size (we don't want to
allow versioining if we are optimizing for size). Please also include that
in the follow up patch.

thanks,
dorit

> > (make sure you pass make info/make dvi, if you haven't yet)
>
> OK.
>
> >
> > So you're going to address the rest of the comments in a separate
> > patch (cost-model updates, improved handling of interleaved-
> > accesses, adding testcases that combine interleaving and versioning-
> > for-aliasing, factoring out the versioning related stuff from
> > vect_transform_loop)? (that would be fine with me, just want to make
> > sure you're planning to address these issues too).
>
> Yes, sure. Just forgot to mention that I'm planing to submit an
> additional patch with performance and other imrovments to versioning for
> alias and above issued will be addressed there.
>
> > so I asked this before: I think you mean "don't perform **peeling**
> > for alignment if versioning for alias is required", right?
>
> Sorry, I'll fix this in the Changelog.
>
> > I think you can use TYPE_VECTOR_SUBPARTS() instead of
> > GET_MODE_SIZE (TYPE_MODE ()) (just a tiny bit more compact)
>
> I think that it slightly different.  For example TYPE_VECTOR_SUBPARTS()
> returns 4 for a vector of integers on ppc, while
> GET_MODE_SIZE (TYPE_MODE ()) returns 16 - size of vector in bytes.
>
> >
> > Also, for more compact code, you could compute the vf*step once and
> > reuse it for both then and else. For your consideration.
> >
> > +     (vinfo_for_stmt (DR_STMT (dr))))));
> > +
> > +      segment_length =
> > + fold_convert (sizetype,
> > +   fold_build2 (PLUS_EXPR, integer_type_node,
> > +     fold_build2 (MULT_EXPR, integer_type_node, DR_STEP (dr),
> > +    vect_factor),
> > +     vector_size));
> > +
> > +
> > +    }
> > +  else
> > +    {
> > +      segment_length =
> > + fold_convert (sizetype,
> > +   fold_build2 (MULT_EXPR, integer_type_node, DR_STEP (dr),
> > +         vect_factor));
> > +    }
> > +
> > +    return segment_length;
> > +}
>
> OK, I'll address this in next patch.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [4.3 projects] Verctorizer - versioning for alias
       [not found] <OFD8F5F2C8.37DFE3DF-ONC2257339.004A59E3-C2257339.004BD2B1@LocalDomain>
@ 2007-08-18  7:54 ` Dorit Nuzman
  2007-08-19  9:20 ` Dorit Nuzman
  2007-08-19 15:13 ` Dorit Nuzman
  2 siblings, 0 replies; 10+ messages in thread
From: Dorit Nuzman @ 2007-08-18  7:54 UTC (permalink / raw)
  To: Victor Kaplansky; +Cc: gcc-patches, rakdver

Victor Kaplansky/Haifa/IBM wrote on 16/08/2007 16:48:11:

> Dorit Nuzman/Haifa/IBM wrote on 16/08/2007 04:11:46 PM:
> >
...
> > I think you can use TYPE_VECTOR_SUBPARTS() instead of
> > GET_MODE_SIZE (TYPE_MODE ()) (just a tiny bit more compact)
>
> I think that it slightly different.  For example TYPE_VECTOR_SUBPARTS()
> returns 4 for a vector of integers on ppc, while
> GET_MODE_SIZE (TYPE_MODE ()) returns 16 - size of vector in bytes.
>

in that case you can use TYPE_SIZE_UNIT ()

dorit

> >
> > Also, for more compact code, you could compute the vf*step once and
> > reuse it for both then and else. For your consideration.
> >
> > +     (vinfo_for_stmt (DR_STMT (dr))))));
> > +
> > +      segment_length =
> > + fold_convert (sizetype,
> > +   fold_build2 (PLUS_EXPR, integer_type_node,
> > +     fold_build2 (MULT_EXPR, integer_type_node, DR_STEP (dr),
> > +    vect_factor),
> > +     vector_size));
> > +
> > +
> > +    }
> > +  else
> > +    {
> > +      segment_length =
> > + fold_convert (sizetype,
> > +   fold_build2 (MULT_EXPR, integer_type_node, DR_STEP (dr),
> > +         vect_factor));
> > +    }
> > +
> > +    return segment_length;
> > +}
>
> OK, I'll address this in next patch.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [4.3 projects] Verctorizer - versioning for alias
       [not found] <OF531586B8.1BD86F22-ONC2257339.0046568C-C2257339.00487D11@LocalDomain>
@ 2007-08-16 13:49 ` Victor Kaplansky
  0 siblings, 0 replies; 10+ messages in thread
From: Victor Kaplansky @ 2007-08-16 13:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: rakdver, Dorit Nuzman



Dorit Nuzman/Haifa/IBM wrote on 16/08/2007 04:11:46 PM:
>
> Is there a testcase that catches this case?

vect-vfa-01.c catches it.

>
> >   - POINTER_PLUS_EXPR used insted of PLUS_EXPR for pointer
> > arithmentics.
> >   - Parameters "vect-max-version-for-alignment-checks" and
> > "vect-max-version-for-alias-checks" documented in invoke.texi.
>
> (make sure you pass make info/make dvi, if you haven't yet)

OK.

>
> So you're going to address the rest of the comments in a separate
> patch (cost-model updates, improved handling of interleaved-
> accesses, adding testcases that combine interleaving and versioning-
> for-aliasing, factoring out the versioning related stuff from
> vect_transform_loop)? (that would be fine with me, just want to make
> sure you're planning to address these issues too).

Yes, sure. Just forgot to mention that I'm planing to submit an
additional patch with performance and other imrovments to versioning for
alias and above issued will be addressed there.

> so I asked this before: I think you mean "don't perform **peeling**
> for alignment if versioning for alias is required", right?

Sorry, I'll fix this in the Changelog.

> I think you can use TYPE_VECTOR_SUBPARTS() instead of
> GET_MODE_SIZE (TYPE_MODE ()) (just a tiny bit more compact)

I think that it slightly different.  For example TYPE_VECTOR_SUBPARTS()
returns 4 for a vector of integers on ppc, while
GET_MODE_SIZE (TYPE_MODE ()) returns 16 - size of vector in bytes.

>
> Also, for more compact code, you could compute the vf*step once and
> reuse it for both then and else. For your consideration.
>
> +     (vinfo_for_stmt (DR_STMT (dr))))));
> +
> +      segment_length =
> + fold_convert (sizetype,
> +   fold_build2 (PLUS_EXPR, integer_type_node,
> +     fold_build2 (MULT_EXPR, integer_type_node, DR_STEP (dr),
> +    vect_factor),
> +     vector_size));
> +
> +
> +    }
> +  else
> +    {
> +      segment_length =
> + fold_convert (sizetype,
> +   fold_build2 (MULT_EXPR, integer_type_node, DR_STEP (dr),
> +         vect_factor));
> +    }
> +
> +    return segment_length;
> +}

OK, I'll address this in next patch.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [4.3 projects] Verctorizer - versioning for alias
  2007-08-16 11:07 ` Victor Kaplansky
@ 2007-08-16 13:09   ` Dorit Nuzman
  0 siblings, 0 replies; 10+ messages in thread
From: Dorit Nuzman @ 2007-08-16 13:09 UTC (permalink / raw)
  To: Victor Kaplansky; +Cc: gcc-patches, rakdver

> Please find below updated patch after implementation of comments
> from Dorit and Zdenek.
>
>   Here is the list of changes from previous patch:
>   - A new testcase when IN and OUT overlap in such a way that
> the vectorized copy of the loop would produce wrong results if
> it were used added(vect-vfa-04.c).
>   - Fixed the size of segment accessed by data reference in cases
> when realignment loads are used.

Is there a testcase that catches this case?

>   - POINTER_PLUS_EXPR used insted of PLUS_EXPR for pointer
> arithmentics.
>   - Parameters "vect-max-version-for-alignment-checks" and
> "vect-max-version-for-alias-checks" documented in invoke.texi.

(make sure you pass make info/make dvi, if you haven't yet)

>   - Fixed typos and unclear comments.
>

So you're going to address the rest of the comments in a separate patch
(cost-model updates, improved handling of interleaved-accesses, adding
testcases that combine interleaving and versioning-for-aliasing, factoring
out the versioning related stuff from vect_transform_loop)? (that would be
fine with me, just want to make sure you're planning to address these
issues too).

>
> Bootstrapped with vectorization enabled on x86_64, regtested on
> x86_64.
> Okay for mainline after boostrap and regression testing on PPC?
>
>
>
> 2007-08-14  Victor Kaplansky <victork@il.ibm.com>
>
> ChangeLog:
>
...
>              (vect_enhance_data_refs_alignment): Define local variable
>              vect_versioning_for_alias_required, don't perform
>              versioning for alignment if versioning for alias is
>              required.

so I asked this before: I think you mean "don't perform **peeling** for
alignment if versioning for alias is required", right?

Lastly, about:

+static tree
+vect_vfa_segment_size (struct data_reference *dr, tree vect_factor)
+{
+  tree segment_length;
+
+  if (vect_supportable_dr_alignment (dr) ==
dr_unaligned_software_pipeline)
+    {
+      tree vector_size =
+        build_int_cst (integer_type_node,
+          GET_MODE_SIZE (TYPE_MODE (STMT_VINFO_VECTYPE

I think you can use TYPE_VECTOR_SUBPARTS() instead of
GET_MODE_SIZE (TYPE_MODE ()) (just a tiny bit more compact)

Also, for more compact code, you could compute the vf*step once and reuse
it for both then and else. For your consideration.

+         (vinfo_for_stmt (DR_STMT (dr))))));
+
+      segment_length =
+     fold_convert (sizetype,
+       fold_build2 (PLUS_EXPR, integer_type_node,
+         fold_build2 (MULT_EXPR, integer_type_node, DR_STEP (dr),
+                  vect_factor),
+         vector_size));
+
+
+    }
+  else
+    {
+      segment_length =
+     fold_convert (sizetype,
+       fold_build2 (MULT_EXPR, integer_type_node, DR_STEP (dr),
+                  vect_factor));
+    }
+
+    return segment_length;
+}

OK otherwise,

thanks,
dorit

> (See attached file: vfa-n.txt)
> [attachment "vfa-n.txt" deleted by Dorit Nuzman/Haifa/IBM]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] [4.3 projects] Verctorizer - versioning for alias
       [not found] <OF128D770D.7C095078-ONC2257337.00562B23-C2257337.005E3D6E@LocalDomain>
@ 2007-08-16 11:07 ` Victor Kaplansky
  2007-08-16 13:09   ` Dorit Nuzman
  0 siblings, 1 reply; 10+ messages in thread
From: Victor Kaplansky @ 2007-08-16 11:07 UTC (permalink / raw)
  To: gcc-patches; +Cc: rakdver

[-- Attachment #1: Type: text/plain, Size: 3296 bytes --]

Please find below updated patch after implementation of comments
from Dorit and Zdenek.

  Here is the list of changes from previous patch:
  - A new testcase when IN and OUT overlap in such a way that
the vectorized copy of the loop would produce wrong results if
it were used added(vect-vfa-04.c).
  - Fixed the size of segment accessed by data reference in cases
when realignment loads are used.
  - POINTER_PLUS_EXPR used insted of PLUS_EXPR for pointer
arithmentics.
  - Parameters "vect-max-version-for-alignment-checks" and
"vect-max-version-for-alias-checks" documented in invoke.texi.
  - Fixed typos and unclear comments.


Bootstrapped with vectorization enabled on x86_64, regtested on
x86_64.
Okay for mainline after boostrap and regression testing on PPC?



2007-08-14  Victor Kaplansky <victork@il.ibm.com>

ChangeLog:

             * tree-vectorizer.c (new_loop_vec_info): Initialize new
             field.
             (destroy_loop_vec_info): Add call to VEC_free.
             * tree-vectorizer.h (may_alias_ddrs): Define.
             (LOOP_VINFO_MAY_ALIAS_DDRS): Define.
             * tree-vect-analyze.c (vect_analyze_data_ref_dependence):
             Change reporting to dump.
             (vect_is_duplicate_ddr): New.
             (vect_mark_for_runtime_alias_test): New.
             (vect_analyze_data_ref_dependences) Add call to
             vect_mark_for_runtime_alias_test.
             (vect_enhance_data_refs_alignment): Define local variable
             vect_versioning_for_alias_required, don't perform
             versioning for alignment if versioning for alias is
             required.
             (vect_enhance_data_refs_alignment): Use
             PARAM_VECT_MAX_VERSION_FOR_ALIGNMENT_CHECKS instead of
             PARAM_VECT_MAX_VERSION_CHECKS.
             * tree-vect-transform.c
             (vect_create_cond_for_alias_checks): New.
             (vect_transform_loop): Add call to
             vect_create_cond_for_alias_checks.
             (vect_vfa_segment_size): New.
             * params.def (PARAM_VECT_MAX_VERSION_FOR_ALIGNMENT_CHECKS):
             Rename.
             (PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS): Define.
             * gcc/doc/invoke.texi
             (vect-max-version-for-alignment-checks): Document.
             (vect-max-version-for-alias-checks): Document.
             (vect-max-version-checks): Remove.


testsuite/ChangeLog:

            * gcc.dg/vect/vect-vfa-01.c: New.
            * gcc.dg/vect/vect-vfa-02.c: New.
            * gcc.dg/vect/vect-vfa-03.c: New.
            * gcc.dg/vect/vect-vfa-04.c: New.
            * gcc.dg/vect/vect-102a.c, gcc.dg/vect/vect-51.c,
            gcc.dg/vect/pr29145.c, gcc.dg/vect/vect-43.c,
            gcc.dg/vect/vect-61.c, gcc.dg/vect/vect-53.c,
            gcc.dg/vect/vect-45.c, gcc.dg/vect/vect-101.c,
            gcc.dg/vect/vect-37.c, gcc.dg/vect/vect-79.c,
            gcc.dg/vect/vect-102.c, gcc.dg/vect/vect-dv-2.c,
            gcc.dg/vect/vect-57.c, gcc.dg/vect/vect-49.c,
            gfortran.dg/vect/pr19049.f90: Rename to start with
            prefix no-vfa-.
            * gcc.dg/vect/vect.exp: Disable versioning for alias
            when test starts with no-vfa-.
            * gfortran.dg/vect/vect.exp: Likewise.

(See attached file: vfa-n.txt)

[-- Attachment #2: vfa-n.txt --]
[-- Type: text/plain, Size: 71898 bytes --]

Index: gcc/params.def
===================================================================
--- gcc/params.def	(revision 127477)
+++ gcc/params.def	(working copy)
@@ -485,11 +485,16 @@
 	 "When set to 1, use expensive methods to eliminate all redundant constraints",
 	 0, 0, 1)
 
-DEFPARAM(PARAM_VECT_MAX_VERSION_CHECKS,
-         "vect-max-version-checks",
-         "Bound on number of runtime checks inserted by the vectorizer's loop versioning",
+DEFPARAM(PARAM_VECT_MAX_VERSION_FOR_ALIGNMENT_CHECKS,
+         "vect-max-version-for-alignment-checks",
+         "Bound on number of runtime checks inserted by the vectorizer's loop versioning for alignment check",
          6, 0, 0)
 
+DEFPARAM(PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS,
+         "vect-max-version-for-alias-checks",
+         "Bound on number of runtime checks inserted by the vectorizer's loop versioning for alias check",
+         10, 0, 0)
+
 DEFPARAM(PARAM_MAX_CSELIB_MEMORY_LOCATIONS,
 	 "max-cselib-memory-locations",
 	 "The maximum memory locations recorded by cselib",
Index: gcc/tree-vect-transform.c
===================================================================
--- gcc/tree-vect-transform.c	(revision 127477)
+++ gcc/tree-vect-transform.c	(working copy)
@@ -5805,7 +5805,147 @@
                  and_tmp_name, ptrsize_zero);
 }
 
+/* Function vect_vfa_segment_size.
 
+   Create an expression that computes the size of segment
+   that will be accessed for a data reference.  The functions takes into
+   account that realignment loads may access one more vector.
+
+   Input:
+     DR: The data reference.
+     VECT_FACTOR: vectorization factor.
+
+   Return an exrpession whose value is the size of segment which will be
+   accessed by DR.  */
+
+static tree
+vect_vfa_segment_size (struct data_reference *dr, tree vect_factor)
+{
+  tree segment_length;
+
+  if (vect_supportable_dr_alignment (dr) == dr_unaligned_software_pipeline)
+    {
+      tree vector_size =
+        build_int_cst (integer_type_node,
+          GET_MODE_SIZE (TYPE_MODE (STMT_VINFO_VECTYPE
+	    (vinfo_for_stmt (DR_STMT (dr))))));
+
+      segment_length =
+	fold_convert (sizetype,
+	  fold_build2 (PLUS_EXPR, integer_type_node,
+	    fold_build2 (MULT_EXPR, integer_type_node, DR_STEP (dr),
+			 vect_factor),
+	    vector_size));
+
+
+    }
+  else
+    {
+      segment_length =
+	fold_convert (sizetype,
+	  fold_build2 (MULT_EXPR, integer_type_node, DR_STEP (dr),
+		       vect_factor));
+    }
+
+    return segment_length;
+}
+
+/* Function vect_create_cond_for_alias_checks.
+
+   Create a conditional expression that represents the run-time checks for
+   overlapping of address ranges represented by a list of data references
+   relations passed as input.
+
+   Input:
+   COND_EXPR  - input conditional expression.  New conditions will be chained
+                with logical and operation.
+   LOOP_VINFO - field LOOP_VINFO_MAY_ALIAS_STMTS contains the list of ddrs
+	        to be checked.
+
+   Output:
+   COND_EXPR - conditional expression.
+   COND_EXPR_STMT_LIST - statements needed to construct the conditional
+                         expression.
+   The returned value is the conditional expression to be used in the if
+   statement that controls which version of the loop gets executed at runtime.
+*/
+
+static void
+vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo,
+				   tree * cond_expr,
+				   tree * cond_expr_stmt_list)
+{
+  VEC (ddr_p, heap) * may_alias_ddrs =
+    LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo);
+  tree vect_factor =
+    build_int_cst (integer_type_node, LOOP_VINFO_VECT_FACTOR (loop_vinfo));
+
+  ddr_p ddr;
+  unsigned int i;
+  tree part_cond_expr;
+
+  /* Create expression
+     ((store_ptr_0 + store_segment_length_0) < load_ptr_0)
+     || (load_ptr_0 + load_segment_length_0) < store_ptr_0))
+     &&         
+     ...
+     &&
+     ((store_ptr_n + store_segment_length_n) < load_ptr_n)
+     || (load_ptr_n + load_segment_length_n) < store_ptr_n))  */
+
+  if (VEC_empty (ddr_p, may_alias_ddrs))
+    return;
+
+  for (i = 0; VEC_iterate (ddr_p, may_alias_ddrs, i, ddr); i++)
+    {
+      tree stmt_a = DR_STMT (DDR_A (ddr));
+      tree stmt_b = DR_STMT (DDR_B (ddr));
+
+      tree addr_base_a =
+        vect_create_addr_base_for_vector_ref (stmt_a, cond_expr_stmt_list,
+					      NULL_TREE);
+      tree addr_base_b =
+        vect_create_addr_base_for_vector_ref (stmt_b, cond_expr_stmt_list,
+					      NULL_TREE);
+
+      tree segment_length_a = vect_vfa_segment_size (DDR_A (ddr), vect_factor);
+      tree segment_length_b = vect_vfa_segment_size (DDR_B (ddr), vect_factor);
+
+      if (vect_print_dump_info (REPORT_DR_DETAILS))
+	{
+	  fprintf (vect_dump,
+		   "create runtime check for data references ");
+	  print_generic_expr (vect_dump, DR_REF (DDR_A (ddr)), TDF_SLIM);
+	  fprintf (vect_dump, " and ");
+	  print_generic_expr (vect_dump, DR_REF (DDR_B (ddr)), TDF_SLIM);
+	}
+
+
+      part_cond_expr = 
+      	fold_build2 (TRUTH_OR_EXPR, boolean_type_node,
+	  fold_build2 (LT_EXPR, boolean_type_node,
+	    fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (addr_base_a),
+	      addr_base_a,
+	      segment_length_a),
+	    addr_base_b),
+	  fold_build2 (LT_EXPR, boolean_type_node,
+	    fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (addr_base_b),
+	      addr_base_b,
+	      segment_length_b),
+	    addr_base_a));
+      
+      if (*cond_expr)
+	*cond_expr = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
+			          *cond_expr, part_cond_expr);
+      else
+	*cond_expr = part_cond_expr;
+    }
+    if (vect_print_dump_info (REPORT_VECTORIZED_LOOPS))
+      fprintf (vect_dump, "created %u versioning for alias checks.\n",
+               VEC_length (ddr_p, may_alias_ddrs));
+
+}
+
 /* Function vect_transform_loop.
 
    The analysis phase has determined that the loop is vectorizable.
@@ -5827,16 +5967,21 @@
   if (vect_print_dump_info (REPORT_DETAILS))
     fprintf (vect_dump, "=== vec_transform_loop ===");
 
-  /* If the loop has data references that may or may not be aligned then
+  /* If the loop has data references that may or may not be aligned or/and
+     has data reference relations whose independence was not proven then
      two versions of the loop need to be generated, one which is vectorized
      and one which isn't.  A test is then generated to control which of the
      loops is executed.  The test checks for the alignment of all of the
-     data references that may or may not be aligned. */
+     data references that may or may not be aligned.  An additional
+     sequence of runtime tests is generated for each pairs of DDRs whose
+     independence was not proven.  The vectorized version of loop is 
+     executed only if both alias and alignment tests are passed.  */
 
-  if (VEC_length (tree, LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo)))
+  if (VEC_length (tree, LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo))
+      || VEC_length (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo)))
     {
       struct loop *nloop;
-      tree cond_expr;
+      tree cond_expr = NULL_TREE;
       tree cond_expr_stmt_list = NULL_TREE;
       basic_block condition_bb;
       block_stmt_iterator cond_exp_bsi;
@@ -5845,9 +5990,23 @@
       edge new_exit_e, e;
       tree orig_phi, new_phi, arg;
       unsigned prob = 4 * REG_BR_PROB_BASE / 5;
+      tree gimplify_stmt_list;
 
-      cond_expr = vect_create_cond_for_align_checks (loop_vinfo,
+      if (VEC_length (tree, LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo)))
+	cond_expr =
+	  vect_create_cond_for_align_checks (loop_vinfo, &cond_expr_stmt_list);
+
+      if (VEC_length (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo)))
+	vect_create_cond_for_alias_checks (loop_vinfo, &cond_expr,
                                                      &cond_expr_stmt_list);
+
+      cond_expr =
+        fold_build2 (NE_EXPR, boolean_type_node, cond_expr, integer_zero_node);
+      cond_expr =
+        force_gimple_operand (cond_expr, &gimplify_stmt_list, true,
+                              NULL_TREE);
+      append_to_statement_list (gimplify_stmt_list, &cond_expr_stmt_list);
+
       initialize_original_copy_tables ();
       nloop = loop_version (loop, cond_expr, &condition_bb,
 			    prob, prob, REG_BR_PROB_BASE - prob, true);
Index: gcc/tree-vect-analyze.c
===================================================================
--- gcc/tree-vect-analyze.c	(revision 127477)
+++ gcc/tree-vect-analyze.c	(working copy)
@@ -1039,10 +1039,10 @@
   
   if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know)
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
+      if (vect_print_dump_info (REPORT_DR_DETAILS))
         {
           fprintf (vect_dump,
-                   "not vectorized: can't determine dependence between ");
+                   "versioning for alias required: can't determine dependence between ");
           print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
           fprintf (vect_dump, " and ");
           print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
@@ -1052,9 +1052,9 @@
 
   if (DDR_NUM_DIST_VECTS (ddr) == 0)
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
+      if (vect_print_dump_info (REPORT_DR_DETAILS))
         {
-          fprintf (vect_dump, "not vectorized: bad dist vector for ");
+          fprintf (vect_dump, "versioning for alias required: bad dist vector for ");
           print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
           fprintf (vect_dump, " and ");
           print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
@@ -1108,10 +1108,11 @@
 	  continue;
 	}
 
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
+      if (vect_print_dump_info (REPORT_DR_DETAILS))
 	{
 	  fprintf (vect_dump,
-		   "not vectorized: possible dependence between data-refs ");
+		   "versioning for alias required: possible dependence "
+		   "between data-refs ");
 	  print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
 	  fprintf (vect_dump, " and ");
 	  print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
@@ -1123,7 +1124,78 @@
   return false;
 }
 
+/* Return TRUE if DDR_NEW is already found in MAY_ALIAS_DDRS list.  */
 
+static bool
+vect_is_duplicate_ddr (VEC (ddr_p, heap) * may_alias_ddrs, ddr_p ddr_new)
+{
+  unsigned i;
+  ddr_p ddr;
+
+  for (i = 0; VEC_iterate (ddr_p, may_alias_ddrs, i, ddr); i++)
+    {
+      tree dref_A_i, dref_B_i, dref_A_j, dref_B_j;
+
+      dref_A_i = DR_REF (DDR_A (ddr));
+      dref_B_i = DR_REF (DDR_B (ddr));
+      dref_A_j = DR_REF (DDR_A (ddr_new));
+      dref_B_j = DR_REF (DDR_B (ddr_new));
+
+      if ((operand_equal_p (dref_A_i, dref_A_j, 0)
+	   && operand_equal_p (dref_B_i, dref_B_j, 0))
+	  || (operand_equal_p (dref_A_i, dref_B_j, 0)
+	      && operand_equal_p (dref_B_i, dref_A_j, 0)))
+	{
+	  if (vect_print_dump_info (REPORT_DR_DETAILS))
+	    {
+	      fprintf (vect_dump, "found same pair of data references ");
+	      print_generic_expr (vect_dump, dref_A_i, TDF_SLIM);
+	      fprintf (vect_dump, " and ");
+	      print_generic_expr (vect_dump, dref_B_i, TDF_SLIM);
+	    }
+	  return true;
+	}
+    }
+  return false;
+}
+
+/* Save DDR in LOOP_VINFO list of ddrs that may alias and need to be
+   tested at run-time.  Returns false if number of run-time checks
+   inserted by vectorizer is greater than maximum defined by
+   PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS.  */
+static bool
+vect_mark_for_runtime_alias_test (ddr_p ddr, loop_vec_info loop_vinfo)
+{
+  if (vect_print_dump_info (REPORT_DR_DETAILS))
+    {
+      fprintf (vect_dump, "mark for run-time aliasing test between ");
+      print_generic_expr (vect_dump, DR_REF (DDR_A (ddr)), TDF_SLIM);
+      fprintf (vect_dump, " and ");
+      print_generic_expr (vect_dump, DR_REF (DDR_B (ddr)), TDF_SLIM);
+    }
+
+  /* Do not add to the list duplicate ddrs.  */
+  if (vect_is_duplicate_ddr (LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo), ddr))
+    return true;
+
+  if (VEC_length (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo))
+      >= (unsigned) PARAM_VALUE (PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS))
+    {
+      if (vect_print_dump_info (REPORT_DR_DETAILS))
+	{
+	  fprintf (vect_dump,
+		   "disable versioning for alias - max number of generated "
+		   "checks exceeded.");
+	}
+
+      VEC_truncate (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo), 0);
+
+      return false;
+    }
+  VEC_safe_push (ddr_p, heap, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo), ddr);
+  return true;
+}
+
 /* Function vect_analyze_data_ref_dependences.
           
    Examine all the data references in the loop, and make sure there do not
@@ -1133,7 +1205,7 @@
 vect_analyze_data_ref_dependences (loop_vec_info loop_vinfo)
 {
   unsigned int i;
-  VEC (ddr_p, heap) *ddrs = LOOP_VINFO_DDRS (loop_vinfo);
+  VEC (ddr_p, heap) * ddrs = LOOP_VINFO_DDRS (loop_vinfo);
   struct data_dependence_relation *ddr;
 
   if (vect_print_dump_info (REPORT_DETAILS)) 
@@ -1141,7 +1213,11 @@
      
   for (i = 0; VEC_iterate (ddr_p, ddrs, i, ddr); i++)
     if (vect_analyze_data_ref_dependence (ddr, loop_vinfo))
+      {
+	/* Add to list of ddrs that need to be tested at run-time.  */
+	if (!vect_mark_for_runtime_alias_test (ddr, loop_vinfo))
       return false;
+      }
 
   return true;
 }
@@ -1554,6 +1630,7 @@
   bool stat;
   tree stmt;
   stmt_vec_info stmt_info;
+  int vect_versioning_for_alias_required;
 
   if (vect_print_dump_info (REPORT_DETAILS))
     fprintf (vect_dump, "=== vect_enhance_data_refs_alignment ===");
@@ -1619,9 +1696,15 @@
 	}
     }
 
-  /* Often peeling for alignment will require peeling for loop-bound, which in 
-     turn requires that we know how to adjust the loop ivs after the loop.  */
-  if (!vect_can_advance_ivs_p (loop_vinfo)
+  vect_versioning_for_alias_required =
+    (VEC_length (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo)) > 0);
+
+  /* Temporarily, if versioning for alias is required, we disable peeling
+     until we support peeling and versioning.  Often peeling for alignment
+     will require peeling for loop-bound, which in turn requires that we
+     know how to adjust the loop ivs after the loop.  */
+  if (vect_versioning_for_alias_required
+       || !vect_can_advance_ivs_p (loop_vinfo)
       || !slpeel_can_duplicate_loop_p (loop, single_exit (loop)))
     do_peeling = false;
 
@@ -1749,7 +1832,7 @@
               if (known_alignment_for_access_p (dr)
                   || VEC_length (tree,
                                  LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo))
-                     >= (unsigned) PARAM_VALUE (PARAM_VECT_MAX_VERSION_CHECKS))
+                     >= (unsigned) PARAM_VALUE (PARAM_VECT_MAX_VERSION_FOR_ALIGNMENT_CHECKS))
                 {
                   do_versioning = false;
                   break;
Index: gcc/tree-vectorizer.h
===================================================================
--- gcc/tree-vectorizer.h	(revision 127477)
+++ gcc/tree-vectorizer.h	(working copy)
@@ -133,6 +133,10 @@
   /* All data dependences in the loop.  */
   VEC (ddr_p, heap) *ddrs;
 
+  /* Data Dependence Relations defining address ranges that are candidates
+     for a run-time aliasing check.  */
+  VEC (ddr_p, heap) *may_alias_ddrs;
+
   /* Statements in the loop that have data references that are candidates for a
      runtime (loop versioning) misalignment check.  */
   VEC(tree,heap) *may_misalign_stmts;
@@ -157,6 +161,7 @@
 #define LOOP_VINFO_UNALIGNED_DR(L)    (L)->unaligned_dr
 #define LOOP_VINFO_MAY_MISALIGN_STMTS(L) (L)->may_misalign_stmts
 #define LOOP_VINFO_LOC(L)             (L)->loop_line_number
+#define LOOP_VINFO_MAY_ALIAS_DDRS(L)  (L)->may_alias_ddrs
 
 #define NITERS_KNOWN_P(n)                     \
 (host_integerp ((n),0)                        \
Index: gcc/tree-vectorizer.c
===================================================================
--- gcc/tree-vectorizer.c	(revision 127477)
+++ gcc/tree-vectorizer.c	(working copy)
@@ -1414,9 +1414,12 @@
   LOOP_VINFO_DATAREFS (res) = VEC_alloc (data_reference_p, heap, 10);
   LOOP_VINFO_DDRS (res) = VEC_alloc (ddr_p, heap, 10 * 10);
   LOOP_VINFO_UNALIGNED_DR (res) = NULL;
-  LOOP_VINFO_MAY_MISALIGN_STMTS (res)
-    = VEC_alloc (tree, heap, PARAM_VALUE (PARAM_VECT_MAX_VERSION_CHECKS));
+  LOOP_VINFO_MAY_MISALIGN_STMTS (res) =
+    VEC_alloc (tree, heap, PARAM_VALUE (PARAM_VECT_MAX_VERSION_FOR_ALIGNMENT_CHECKS));
+  LOOP_VINFO_MAY_ALIAS_DDRS (res) =
+    VEC_alloc (ddr_p, heap, PARAM_VALUE (PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS));
 
+
   return res;
 }
 
@@ -1495,6 +1498,7 @@
   free_data_refs (LOOP_VINFO_DATAREFS (loop_vinfo));
   free_dependence_relations (LOOP_VINFO_DDRS (loop_vinfo));
   VEC_free (tree, heap, LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo));
+  VEC_free (ddr_p, heap, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo));
 
   free (loop_vinfo);
   loop->aux = NULL;
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 127477)
+++ gcc/doc/invoke.texi	(working copy)
@@ -6741,11 +6741,16 @@
 When set to 1, use expensive methods to eliminate all redundant
 constraints.  The default value is 0.
 
-@item vect-max-version-checks
-The maximum number of runtime checks that can be performed when doing
-loop versioning in the vectorizer.  See option ftree-vect-loop-version
-for more information.
+@item vect-max-version-for-alignment-checks
+The maximum number of runtime checks that can be performed when
+doing loop versioning for alignment in the vectorizer.  See option
+ftree-vect-loop-version for more information.
 
+@item vect-max-version-for-alias-checks
+The maximum number of runtime checks that can be performed when
+doing loop versioning for alias in the vectorizer.  See option
+ftree-vect-loop-version for more information.
+
 @item max-iterations-to-track
 
 The maximum number of iterations of a loop the brute force algorithm
Index: gcc/testsuite/gfortran.dg/vect/vect.exp
===================================================================
--- gcc/testsuite/gfortran.dg/vect/vect.exp	(revision 127477)
+++ gcc/testsuite/gfortran.dg/vect/vect.exp	(working copy)
@@ -90,8 +90,19 @@
 dg-init
 
 # Main loop.
-gfortran-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03} ]] $DEFAULT_VECTCFLAGS
+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
 
+#### Tests with special options
+global SAVED_DEFAULT_VECTCFLAGS
+set SAVED_DEFAULT_VECTCFLAGS $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"
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-vfa-*.\[fF\]{,90,95,03} ]]  \
+        "" $DEFAULT_VECTCFLAGS
+
 # Clean up.
 set dg-do-what-default ${save-dg-do-what-default}
 
Index: gcc/testsuite/gcc.dg/vect/vect.exp
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect.exp	(revision 127477)
+++ gcc/testsuite/gcc.dg/vect/vect.exp	(working copy)
@@ -113,6 +113,12 @@
 global SAVED_DEFAULT_VECTCFLAGS
 set SAVED_DEFAULT_VECTCFLAGS $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"
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/no-vfa-*.\[cS\]]]  \
+	"" $DEFAULT_VECTCFLAGS
+
 # -ffast-math tests
 set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
 lappend DEFAULT_VECTCFLAGS "-ffast-math"
Index: gcc/testsuite/gcc.dg/vect/vect-vfa-01.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-vfa-01.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/vect-vfa-01.c	(revision 0)
@@ -0,0 +1,39 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+int result[N] = {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27};
+int X[N] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25};
+int Y[N] = {};
+ 
+void
+foo (int *in, int *out)
+{  
+  int i;
+  
+  for (i = 0; i < N; i++)
+    out[i] = in[i] + 2;
+}
+
+int
+main (void)
+{ 
+  int i;
+
+  check_vect ();
+
+  foo (X, Y);
+  
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (Y[i] != result[i])
+	abort ();
+    }
+  return 0;
+} 
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/vect-vfa-02.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-vfa-02.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/vect-vfa-02.c	(revision 0)
@@ -0,0 +1,47 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+int resultY[N] = {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27};
+int resultZ[N] = {13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28};
+int X[N] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25};
+int Y[N] = {};
+int Z[N] = {};
+ 
+void
+foo (int *in, int *out1, int *out2)
+{
+  int i;
+
+  for (i = 0; i < N; i++)
+    {
+      out1[i] = in[i] + 2;
+      out2[i] = in[i] + 3;
+    }
+}
+
+int
+main (void)
+{ 
+  int i;
+
+  check_vect ();
+
+  foo (X, Y, Z);
+  
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (Y[i] != resultY[i])
+	abort ();
+
+      if (Z[i] != resultZ[i])
+	abort ();
+    }
+  return 0;
+} 
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/vect-vfa-03.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-vfa-03.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/vect-vfa-03.c	(revision 0)
@@ -0,0 +1,58 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+struct S
+{
+  unsigned short a;
+  unsigned short b;
+};
+
+struct S result[N] = {12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18,
+                      18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24,
+		      24, 25, 25, 26, 26, 27, 27, 28};
+struct S X[N] = {10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16,
+                 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
+		 23, 23, 24, 24, 25, 25};
+struct S Y[N] = {};
+ 
+void
+foo (struct S * in, struct S * out)
+{
+  int i;
+
+  for (i = 0; i < N; i++)
+    {
+      out[i].a = in[i].a + 2;
+      out[i].b = in[i].b + 3;
+    }
+}
+
+int
+main (void)
+{ 
+  int i;
+
+  check_vect ();
+
+  foo (X, Y);
+  
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (Y[i].a != result[i].a)
+	abort ();
+
+      if (Y[i].b != result[i].b)
+	abort ();
+
+    }
+  return 0;
+} 
+
+/* Needs interleaving support.  */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_interleave && vect_extract_even_odd } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { xfail  { vect_interleave && vect_extract_even_odd } } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/vect-vfa-04.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-vfa-04.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/vect-vfa-04.c	(revision 0)
@@ -0,0 +1,38 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+int result[] = {10, 11, 15, 16, 20, 21, 25, 26, 30, 31, 35, 36, 40, 41, 45, 46, 50, 51};
+int X[] =      {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0};
+ 
+void
+foo (int *in, int *out)
+{  
+  int i;
+  
+  for (i = 0; i < N; i++)
+    out[i] = in[i] + 5;
+}
+
+int
+main (void)
+{ 
+  int i;
+
+  check_vect ();
+
+  foo (X, &X[2]);
+  
+  /* check results:  */
+  for (i = 0; i < N+2; i++)
+    {
+      if (X[i] != result[i])
+	abort ();
+    }
+  return 0;
+} 
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/no-vfa-vect-53.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-53.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-53.c	(revision 0)
@@ -0,0 +1,62 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (const float *pa, const float *pb, const float *pc) 
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != (pb[i] * pc[i]))
+	abort ();
+    }
+
+  return;
+}
+
+/* Unaligned pointer read accesses, aligned pointer write access.
+   The loop bound is unknown.
+   Can't prove that the pointers don't alias.
+   vect-49.c is similar to this one with one difference:
+        the loop bound is known.
+   vect-52.c is similar to this one with one difference:
+        aliasing is not a problem.  */
+
+int
+main1 (int n, float *pb, float *pc)
+{
+  float pa[N] __attribute__ ((__aligned__(16)));
+  int i;
+
+  for (i = 0; i < n; i++)
+    {
+      pa[i] = pb[i] * pc[i];
+    }
+
+  bar (pa,pb,pc);
+
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  float a[N] __attribute__ ((__aligned__(16)));
+  float b[N+1] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60};
+  float c[N+1] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
+
+  check_vect ();
+
+  main1 (N,&b[1],c);
+  main1 (N,&b[1],&c[1]);
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/vect-102a.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-102a.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/vect-102a.c	(working copy)
@@ -1,57 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 9
-
-struct extraction
-{
-  int a[N];
-  int b[N];
-};
-
-static int a[N] = {1,2,3,4,5,6,7,8,9};
-static int b[N] = {2,3,4,5,6,7,8,9,9};
-volatile int foo;
-
-int main1 (int x, int y) {
-  int i;
-  struct extraction *p;
-  p = (struct extraction *) malloc (sizeof (struct extraction));
-
-  for (i = 0; i < N; i++)
-    {
-       p->a[i] = a[i];
-       if (foo == 135)
-	 abort (); /* to avoid vectorization  */
-    }
-
-  /* Not vectorizable: distance 1.  */
-  for (i = 0; i < N - 1; i++)
-    {
-       p->a[x + i] = p->a[x + i + 1];
-    }
-
-  /* check results: */
-  for (i = 0; i < N; i++)
-    {
-       if (p->a[i] != b[i])
-         abort();
-    }
-  return 0;
-}
-
-int main (void)
-{ 
-  check_vect ();
-
-  foo = 0;
-  return main1 (0, N);
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
-/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
-
Index: gcc/testsuite/gcc.dg/vect/no-vfa-vect-45.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-45.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-45.c	(revision 0)
@@ -0,0 +1,59 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (const float *pa, const float *pb, const float *pc) 
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != (pb[i] * pc[i]))
+	abort ();
+    }
+
+  return;
+}
+
+/* Unaligned pointer accesses, with unknown alignment.
+   The loop bound is known and divisible by the vectorization factor.
+   Can't prove that the pointers don't alias.
+   vect-51.c is similar to this one with one difference:
+        the loop bound is unknown.
+   vect-44.c is similar to this one with one difference:
+        Aliasing is not a problem.  */
+
+int
+main1 (float *pa, float *pb, float *pc)
+{
+  int i;
+
+  for (i = 0; i < N; i++)
+    {
+      pa[i] = pb[i] * pc[i];
+    }
+
+  bar (pa,pb,pc);
+
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  float a[N];
+  float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
+  float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+
+  check_vect ();
+
+  main1 (a,b,c);
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/no-vfa-vect-37.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-37.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-37.c	(revision 0)
@@ -0,0 +1,61 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+char x[N] __attribute__ ((__aligned__(16)));
+ 
+int main1 (char *y)
+{  
+  struct {
+    char *p;
+    char *q;
+  } s;
+  char cb[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
+  int i;
+
+  /* Not vectorized - can't antialias the pointer s.p from the array cb.  */
+  s.p = y;
+  for (i = 0; i < N; i++)
+    {
+      s.p[i] = cb[i];
+    }
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (s.p[i] != cb[i])
+        abort ();
+    }
+
+  /* Not vectorized - can't antialias the pointer s.p from the pointer s.q.  */
+  s.q = cb;
+  for (i = 0; i < N; i++)
+    {
+      s.p[i] = s.q[i];
+    }
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (s.p[i] != s.q[i])
+        abort ();
+    }
+
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+  
+  return main1 (x);
+} 
+
+/* Currently the loops fail to vectorize due to aliasing problems.
+   If/when the aliasing problems are resolved, unalignment may
+   prevent vectorization on some targets.  */
+/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "can't determine dependence between" 2 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/no-vfa-vect-79.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-79.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-79.c	(revision 0)
@@ -0,0 +1,50 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+
+float fa[N] __attribute__ ((__aligned__(16)));
+float fb[N+4] __attribute__ ((__aligned__(16))) = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 7.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0};
+float fc[N] __attribute__ ((__aligned__(16))) = {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 7.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5};
+
+/* Like vect-80.c but the pointers are not annotated as restricted,
+   and therefore can't be antialiased.  */
+
+int
+main1 (float *pa, float *pb, float *pc)
+{
+  int i;
+  float *q = pb + 4;
+
+  for (i = 0; i < N; i++)
+    {
+      pa[i] = q[i] * pc[i];
+    }
+
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != q[i] * pc[i])
+	abort();
+    }
+  
+  return 0;
+}
+
+
+int main (void)
+{ 
+  check_vect ();
+
+  main1 (fa, fb, fc);
+
+  return 0;	
+}
+
+/* Currently the loops fail to vectorize due to aliasing problems.
+  If/when the aliasing problems are resolved, unalignment may
+  prevent vectorization on some targets.  */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "can't determine dependence between" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/vect-51.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-51.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/vect-51.c	(working copy)
@@ -1,59 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (const float *pa, const float *pb, const float *pc) 
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != (pb[i] * pc[i]))
-	abort ();
-    }
-
-  return;
-}
-
-/* Unaligned pointer accesses, with unknown alignment.
-   The loop bound is unknown.
-   Can't prove that the pointers don't alias.
-   vect-45.c is similar to this one with one difference:
-        the loop bound is known.
-   vect-50.c is similar to this one with one difference:
-        Aliasing is not a problem.  */
-
-int
-main1 (int n, float *pa, float *pb, float *pc)
-{
-  int i;
-
-  for (i = 0; i < n; i++)
-    {
-      pa[i] = pb[i] * pc[i];
-    }
-
-  bar (pa,pb,pc);
-
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  float a[N];
-  float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
-  float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-
-  check_vect ();
-
-  main1 (N,a,b,c);
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/pr29145.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/pr29145.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/pr29145.c	(working copy)
@@ -1,48 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-void with_restrict(int * __restrict p)
-{
-  int i;
-  int *q = p - 2;
-
-  for (i = 0; i < 1000; ++i) {
-    p[i] = q[i];
-  }
-}
-
-void without_restrict(int * p)
-{
-  int i;
-  int *q = p - 2;
-
-  for (i = 0; i < 1000; ++i) {
-    p[i] = q[i];
-  }
-}
-
-int main(void)
-{
-  int i;
-  int a[1002];
-  int b[1002];
-
-  for (i = 0; i < 1002; ++i) {
-    a[i] = b[i] = i;
-  }
-
-  with_restrict(a + 2);
-  without_restrict(b + 2);
-
-  for (i = 0; i < 1002; ++i) {
-    if (a[i] != b[i])
-      abort();
-  }
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect"  } } */
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/no-vfa-vect-102a.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-102a.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-102a.c	(revision 0)
@@ -0,0 +1,57 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 9
+
+struct extraction
+{
+  int a[N];
+  int b[N];
+};
+
+static int a[N] = {1,2,3,4,5,6,7,8,9};
+static int b[N] = {2,3,4,5,6,7,8,9,9};
+volatile int foo;
+
+int main1 (int x, int y) {
+  int i;
+  struct extraction *p;
+  p = (struct extraction *) malloc (sizeof (struct extraction));
+
+  for (i = 0; i < N; i++)
+    {
+       p->a[i] = a[i];
+       if (foo == 135)
+	 abort (); /* to avoid vectorization  */
+    }
+
+  /* Not vectorizable: distance 1.  */
+  for (i = 0; i < N - 1; i++)
+    {
+       p->a[x + i] = p->a[x + i + 1];
+    }
+
+  /* check results: */
+  for (i = 0; i < N; i++)
+    {
+       if (p->a[i] != b[i])
+         abort();
+    }
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+
+  foo = 0;
+  return main1 (0, N);
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
+/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
Index: gcc/testsuite/gcc.dg/vect/vect-43.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-43.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/vect-43.c	(working copy)
@@ -1,78 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (float *pa, float *pb, float *pc) 
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != (pb[i] * pc[i]))
-	abort ();
-    }
-
-  return;
-}
-
-
-int
-main1 (float *pa)
-{
-  int i;
-  float pb[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
-  float pc[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-
- /* Not vectorizable: pa may alias pb and/or pc, since their addresses escape.  */
-  for (i = 0; i < N; i++)
-    {
-      pa[i] = pb[i] * pc[i];
-    }
-
-  bar (pa,pb,pc);
-
-  return 0;
-}
-
-int
-main2 (float * pa)
-{
-  int i;
-  float pb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
-  float pc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-
-  /* Vectorizable: pb and pc addresses do not escape.  */
-  for (i = 0; i < N; i++)
-    {
-      pa[i] = pb[i] * pc[i];
-    }   
-  
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != (pb[i] * pc[i]))
-        abort ();
-    }
-  
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  float a[N] __attribute__ ((__aligned__(16)));
-
-  check_vect ();
-
-  main1 (a);
-  main2 (a);
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
-/*  { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target vect_no_align } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/no-vfa-vect-101.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-101.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-101.c	(revision 0)
@@ -0,0 +1,49 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 9
+
+struct extraction
+{
+  int a[N];
+  int b[N];
+};
+
+static int a[N] = {1,2,3,4,5,6,7,8,9};
+static int b[N] = {2,3,4,5,6,7,8,9,0};
+
+int main1 (int x, int y) {
+  int i;
+  struct extraction *p;
+  p = (struct extraction *) malloc (sizeof (struct extraction));
+
+  /* Not vectorizable: different unknown offset.  */
+  for (i = 0; i < N; i++)
+    {
+      *((int *)p + x + i) = a[i];
+      *((int *)p + y + i) = b[i];
+    }
+
+  /* check results: */
+  for (i = 0; i < N; i++)
+    {
+       if (p->a[i] != a[i] || p->b[i] != b[i])
+         abort();
+    }
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+
+  return main1 (0, N);
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
+/* { dg-final { scan-tree-dump-times "can't determine dependence" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
Index: gcc/testsuite/gcc.dg/vect/vect-61.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-61.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/vect-61.c	(working copy)
@@ -1,64 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (float *pa, float *pb, float *pc)
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N/2; i++)
-    {
-      if (pa[i] != (pb[i+1] * pc[i+1]))
-	abort ();
-    }
-
-  return;
-}
-
-/* Unaligned pointer read accesses with known alignment,
-   and an unaligned write access with unknown alignment.
-   The loop bound is iunknown.
-   Can't prove that the pointers don't alias.
-   vect-57.c is similar to this one with one difference:
-        the loop bound is known.
-   vect-60.c is similar to this one with two differences:
-        aliasing is not a problem, and the write access is unaligned.  */
-
-int
-main1 (int n , float *pa)
-{
-  int i;
-  float b[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
-  float c[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-  float *pb = b;
-  float *pc = c;
-
-  for (i = 0; i < n/2; i++)
-    {
-      pa[i] = pb[i+1] * pc[i+1];
-    }
-
-  bar (pa,pb,pc);
-
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  int n=N;
-  float a[N] __attribute__ ((__aligned__(16)));
-
-  check_vect ();
-  main1 (n,a);
-
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/vect-53.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-53.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/vect-53.c	(working copy)
@@ -1,62 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (const float *pa, const float *pb, const float *pc) 
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != (pb[i] * pc[i]))
-	abort ();
-    }
-
-  return;
-}
-
-/* Unaligned pointer read accesses, aligned pointer write access.
-   The loop bound is unknown.
-   Can't prove that the pointers don't alias.
-   vect-49.c is similar to this one with one difference:
-        the loop bound is known.
-   vect-52.c is similar to this one with one difference:
-        aliasing is not a problem.  */
-
-int
-main1 (int n, float *pb, float *pc)
-{
-  float pa[N] __attribute__ ((__aligned__(16)));
-  int i;
-
-  for (i = 0; i < n; i++)
-    {
-      pa[i] = pb[i] * pc[i];
-    }
-
-  bar (pa,pb,pc);
-
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  float a[N] __attribute__ ((__aligned__(16)));
-  float b[N+1] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60};
-  float c[N+1] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
-
-  check_vect ();
-
-  main1 (N,&b[1],c);
-  main1 (N,&b[1],&c[1]);
-
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/no-vfa-vect-102.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-102.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-102.c	(revision 0)
@@ -0,0 +1,57 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 9
+
+struct extraction
+{
+  int a[N];
+  int b[N];
+};
+
+static int a[N] = {1,2,3,4,5,6,7,8,9};
+static int b[N] = {2,3,4,5,6,7,8,9,9};
+volatile int foo;
+
+int main1 (int x, int y) {
+  int i;
+  struct extraction *p;
+  p = (struct extraction *) malloc (sizeof (struct extraction));
+
+  for (i = 0; i < N; i++)
+    {
+       p->a[i] = a[i];
+       if (foo == 135)
+	 abort (); /* to avoid vectorization  */
+    }
+
+  /* Not vectorizable: distance 1.  */
+  for (i = 0; i < N - 1; i++)
+    {
+       *((int *)p + x + i) = *((int *)p + x + i + 1);
+    }
+
+  /* check results: */
+  for (i = 0; i < N; i++)
+    {
+       if (p->a[i] != b[i])
+         abort();
+    }
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+
+  foo = 0;
+  return main1 (0, N);
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
+/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
Index: gcc/testsuite/gcc.dg/vect/vect-45.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-45.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/vect-45.c	(working copy)
@@ -1,59 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (const float *pa, const float *pb, const float *pc) 
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != (pb[i] * pc[i]))
-	abort ();
-    }
-
-  return;
-}
-
-/* Unaligned pointer accesses, with unknown alignment.
-   The loop bound is known and divisible by the vectorization factor.
-   Can't prove that the pointers don't alias.
-   vect-51.c is similar to this one with one difference:
-        the loop bound is unknown.
-   vect-44.c is similar to this one with one difference:
-        Aliasing is not a problem.  */
-
-int
-main1 (float *pa, float *pb, float *pc)
-{
-  int i;
-
-  for (i = 0; i < N; i++)
-    {
-      pa[i] = pb[i] * pc[i];
-    }
-
-  bar (pa,pb,pc);
-
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  float a[N];
-  float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
-  float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-
-  check_vect ();
-
-  main1 (a,b,c);
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/vect-101.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-101.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/vect-101.c	(working copy)
@@ -1,49 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 9
-
-struct extraction
-{
-  int a[N];
-  int b[N];
-};
-
-static int a[N] = {1,2,3,4,5,6,7,8,9};
-static int b[N] = {2,3,4,5,6,7,8,9,0};
-
-int main1 (int x, int y) {
-  int i;
-  struct extraction *p;
-  p = (struct extraction *) malloc (sizeof (struct extraction));
-
-  /* Not vectorizable: different unknown offset.  */
-  for (i = 0; i < N; i++)
-    {
-      *((int *)p + x + i) = a[i];
-      *((int *)p + y + i) = b[i];
-    }
-
-  /* check results: */
-  for (i = 0; i < N; i++)
-    {
-       if (p->a[i] != a[i] || p->b[i] != b[i])
-         abort();
-    }
-  return 0;
-}
-
-int main (void)
-{ 
-  check_vect ();
-
-  return main1 (0, N);
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
-/* { dg-final { scan-tree-dump-times "can't determine dependence" 1 "vect" } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
-
Index: gcc/testsuite/gcc.dg/vect/no-vfa-vect-57.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-57.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-57.c	(revision 0)
@@ -0,0 +1,62 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (float *pa, float *pb, float *pc)
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N/2; i++)
+    {
+      if (pa[i] != (pb[i+1] * pc[i+1]))
+        abort ();
+    }
+
+  return;
+}
+
+/* Unaligned pointer read accesses with known alignment,
+   and an unaligned write access with unknown alignment.
+   The loop bound is known and divisible by the vectorization factor.
+   Can't prove that the pointers don't alias.
+   vect-61.c is similar to this one with one difference:
+        the loop bound is unknown.
+   vect-56.c is similar to this one with two differences:
+        aliasing is a problem, and the write access is aligned.  */
+
+int
+main1 (float *pa)
+{
+  int i;
+  float b[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
+  float c[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+  float *pb = b;
+  float *pc = c;
+
+  for (i = 0; i < N/2; i++)
+    {
+      pa[i] = pb[i+1] * pc[i+1];
+    }
+
+  bar (pa, pb, pc);
+
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  float a[N] __attribute__ ((__aligned__(16)));
+
+  check_vect ();
+  main1 (a);
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/vect-37.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-37.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/vect-37.c	(working copy)
@@ -1,61 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 16
-char x[N] __attribute__ ((__aligned__(16)));
- 
-int main1 (char *y)
-{  
-  struct {
-    char *p;
-    char *q;
-  } s;
-  char cb[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
-  int i;
-
-  /* Not vectorized - can't antialias the pointer s.p from the array cb.  */
-  s.p = y;
-  for (i = 0; i < N; i++)
-    {
-      s.p[i] = cb[i];
-    }
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (s.p[i] != cb[i])
-        abort ();
-    }
-
-  /* Not vectorized - can't antialias the pointer s.p from the pointer s.q.  */
-  s.q = cb;
-  for (i = 0; i < N; i++)
-    {
-      s.p[i] = s.q[i];
-    }
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (s.p[i] != s.q[i])
-        abort ();
-    }
-
-  return 0;
-}
-
-int main (void)
-{ 
-  check_vect ();
-  
-  return main1 (x);
-} 
-
-/* Currently the loops fail to vectorize due to aliasing problems.
-   If/when the aliasing problems are resolved, unalignment may
-   prevent vectorization on some targets.  */
-/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "can't determine dependence between" 2 "vect" } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/vect-79.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-79.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/vect-79.c	(working copy)
@@ -1,50 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 16
-
-float fa[N] __attribute__ ((__aligned__(16)));
-float fb[N+4] __attribute__ ((__aligned__(16))) = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 7.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0};
-float fc[N] __attribute__ ((__aligned__(16))) = {0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 7.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5};
-
-/* Like vect-80.c but the pointers are not annotated as restricted,
-   and therefore can't be antialiased.  */
-
-int
-main1 (float *pa, float *pb, float *pc)
-{
-  int i;
-  float *q = pb + 4;
-
-  for (i = 0; i < N; i++)
-    {
-      pa[i] = q[i] * pc[i];
-    }
-
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != q[i] * pc[i])
-	abort();
-    }
-  
-  return 0;
-}
-
-
-int main (void)
-{ 
-  check_vect ();
-
-  main1 (fa, fb, fc);
-
-  return 0;	
-}
-
-/* Currently the loops fail to vectorize due to aliasing problems.
-  If/when the aliasing problems are resolved, unalignment may
-  prevent vectorization on some targets.  */
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "can't determine dependence between" 1 "vect" } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/no-vfa-vect-49.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-49.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-49.c	(revision 0)
@@ -0,0 +1,61 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (float *pa, float *pb, float *pc) 
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != (pb[i] * pc[i]))
+	abort ();
+    }
+
+  return;
+}
+
+/* Unaligned pointer read accesses, aligned pointer write access.
+   The loop bound is known and divisible by the vectorization factor.
+   Can't prove that the pointers don't alias.
+   vect-53.c is similar to this one with one difference:
+        the loop bound is unknown.
+   vect-48.c is similar to this one with one difference:
+        aliasing is not a problem.  */
+
+int
+main1 (float *pb, float *pc)
+{
+  float pa[N] __attribute__ ((__aligned__(16)));
+  int i;
+
+  for (i = 0; i < N; i++)
+    {
+      pa[i] = pb[i] * pc[i];
+    }
+
+  bar (pa,pb,pc);
+
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  float b[N+1] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60};
+  float c[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+
+  check_vect ();
+
+  main1 (b,c);
+  main1 (&b[1],c);
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/vect-102.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-102.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/vect-102.c	(working copy)
@@ -1,57 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 9
-
-struct extraction
-{
-  int a[N];
-  int b[N];
-};
-
-static int a[N] = {1,2,3,4,5,6,7,8,9};
-static int b[N] = {2,3,4,5,6,7,8,9,9};
-volatile int foo;
-
-int main1 (int x, int y) {
-  int i;
-  struct extraction *p;
-  p = (struct extraction *) malloc (sizeof (struct extraction));
-
-  for (i = 0; i < N; i++)
-    {
-       p->a[i] = a[i];
-       if (foo == 135)
-	 abort (); /* to avoid vectorization  */
-    }
-
-  /* Not vectorizable: distance 1.  */
-  for (i = 0; i < N - 1; i++)
-    {
-       *((int *)p + x + i) = *((int *)p + x + i + 1);
-    }
-
-  /* check results: */
-  for (i = 0; i < N; i++)
-    {
-       if (p->a[i] != b[i])
-         abort();
-    }
-  return 0;
-}
-
-int main (void)
-{ 
-  check_vect ();
-
-  foo = 0;
-  return main1 (0, N);
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
-/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
-
Index: gcc/testsuite/gcc.dg/vect/no-vfa-vect-51.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-51.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-51.c	(revision 0)
@@ -0,0 +1,59 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (const float *pa, const float *pb, const float *pc) 
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != (pb[i] * pc[i]))
+	abort ();
+    }
+
+  return;
+}
+
+/* Unaligned pointer accesses, with unknown alignment.
+   The loop bound is unknown.
+   Can't prove that the pointers don't alias.
+   vect-45.c is similar to this one with one difference:
+        the loop bound is known.
+   vect-50.c is similar to this one with one difference:
+        Aliasing is not a problem.  */
+
+int
+main1 (int n, float *pa, float *pb, float *pc)
+{
+  int i;
+
+  for (i = 0; i < n; i++)
+    {
+      pa[i] = pb[i] * pc[i];
+    }
+
+  bar (pa,pb,pc);
+
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  float a[N];
+  float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
+  float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+
+  check_vect ();
+
+  main1 (N,a,b,c);
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/no-vfa-pr29145.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-pr29145.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-pr29145.c	(revision 0)
@@ -0,0 +1,48 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+void with_restrict(int * __restrict p)
+{
+  int i;
+  int *q = p - 2;
+
+  for (i = 0; i < 1000; ++i) {
+    p[i] = q[i];
+  }
+}
+
+void without_restrict(int * p)
+{
+  int i;
+  int *q = p - 2;
+
+  for (i = 0; i < 1000; ++i) {
+    p[i] = q[i];
+  }
+}
+
+int main(void)
+{
+  int i;
+  int a[1002];
+  int b[1002];
+
+  for (i = 0; i < 1002; ++i) {
+    a[i] = b[i] = i;
+  }
+
+  with_restrict(a + 2);
+  without_restrict(b + 2);
+
+  for (i = 0; i < 1002; ++i) {
+    if (a[i] != b[i])
+      abort();
+  }
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect"  } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/vect-dv-2.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-dv-2.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/vect-dv-2.c	(working copy)
@@ -1,77 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-
-#include <stdarg.h>
-#include <signal.h>
-#include "tree-vect.h"
-
-#define N 64
-#define MAX 42
-
-extern void abort(void); 
-
-int main ()
-{  
-  int A[N];
-  int B[N];
-  int C[N];
-  int D[N];
-
-  int i, j;
-
-  check_vect ();
-
-  for (i = 0; i < N; i++)
-    {
-      A[i] = i;
-      B[i] = i;
-      C[i] = i;
-      D[i] = i;
-    }
-
-  /* Vectorizable */
-  for (i = 0; i < N-20; i++)
-    {
-      A[i] = A[i+20];
-    }
-
-  /* check results:  */
-  for (i = 0; i < N-20; i++)
-    {
-      if (A[i] != D[i+20])
-	abort ();
-    }
-
-  /* Vectorizable */
-  for (i = 0; i < 16; i++)
-    {
-      B[i] = B[i] + 5;
-    }
-
-  /* check results:  */
-  for (i = 0; i < 16; i++)
-    {
-      if (B[i] != C[i] + 5)
-	abort ();
-    }
-
-  /* Not vectorizable */
-  for (i = 0; i < 4; i++)
-    {
-      C[i] = C[i+3];
-    }
-
-  /* check results:  */
-  for (i = 0; i < 4; i++)
-    {
-      if (C[i] != D[i+3])
-	abort ();
-    }
-
-  return 0;
-}
-
-
-/* The initialization induction loop (with aligned access) is also vectorized.  */
-/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */
-/* { dg-final { scan-tree-dump-times "accesses have the same alignment." 2 "vect" } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/no-vfa-vect-43.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-43.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-43.c	(revision 0)
@@ -0,0 +1,78 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (float *pa, float *pb, float *pc) 
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != (pb[i] * pc[i]))
+	abort ();
+    }
+
+  return;
+}
+
+
+int
+main1 (float *pa)
+{
+  int i;
+  float pb[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
+  float pc[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+
+ /* Not vectorizable: pa may alias pb and/or pc, since their addresses escape.  */
+  for (i = 0; i < N; i++)
+    {
+      pa[i] = pb[i] * pc[i];
+    }
+
+  bar (pa,pb,pc);
+
+  return 0;
+}
+
+int
+main2 (float * pa)
+{
+  int i;
+  float pb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
+  float pc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+
+  /* Vectorizable: pb and pc addresses do not escape.  */
+  for (i = 0; i < N; i++)
+    {
+      pa[i] = pb[i] * pc[i];
+    }   
+  
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (pa[i] != (pb[i] * pc[i]))
+        abort ();
+    }
+  
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  float a[N] __attribute__ ((__aligned__(16)));
+
+  check_vect ();
+
+  main1 (a);
+  main2 (a);
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/*  { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target vect_no_align } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/vect-57.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-57.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/vect-57.c	(working copy)
@@ -1,62 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (float *pa, float *pb, float *pc)
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N/2; i++)
-    {
-      if (pa[i] != (pb[i+1] * pc[i+1]))
-        abort ();
-    }
-
-  return;
-}
-
-/* Unaligned pointer read accesses with known alignment,
-   and an unaligned write access with unknown alignment.
-   The loop bound is known and divisible by the vectorization factor.
-   Can't prove that the pointers don't alias.
-   vect-61.c is similar to this one with one difference:
-        the loop bound is unknown.
-   vect-56.c is similar to this one with two differences:
-        aliasing is a problem, and the write access is aligned.  */
-
-int
-main1 (float *pa)
-{
-  int i;
-  float b[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
-  float c[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-  float *pb = b;
-  float *pc = c;
-
-  for (i = 0; i < N/2; i++)
-    {
-      pa[i] = pb[i+1] * pc[i+1];
-    }
-
-  bar (pa, pb, pc);
-
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  float a[N] __attribute__ ((__aligned__(16)));
-
-  check_vect ();
-  main1 (a);
-
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/no-vfa-vect-dv-2.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-dv-2.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-dv-2.c	(revision 0)
@@ -0,0 +1,77 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include <signal.h>
+#include "tree-vect.h"
+
+#define N 64
+#define MAX 42
+
+extern void abort(void); 
+
+int main ()
+{  
+  int A[N];
+  int B[N];
+  int C[N];
+  int D[N];
+
+  int i, j;
+
+  check_vect ();
+
+  for (i = 0; i < N; i++)
+    {
+      A[i] = i;
+      B[i] = i;
+      C[i] = i;
+      D[i] = i;
+    }
+
+  /* Vectorizable */
+  for (i = 0; i < N-20; i++)
+    {
+      A[i] = A[i+20];
+    }
+
+  /* check results:  */
+  for (i = 0; i < N-20; i++)
+    {
+      if (A[i] != D[i+20])
+	abort ();
+    }
+
+  /* Vectorizable */
+  for (i = 0; i < 16; i++)
+    {
+      B[i] = B[i] + 5;
+    }
+
+  /* check results:  */
+  for (i = 0; i < 16; i++)
+    {
+      if (B[i] != C[i] + 5)
+	abort ();
+    }
+
+  /* Not vectorizable */
+  for (i = 0; i < 4; i++)
+    {
+      C[i] = C[i+3];
+    }
+
+  /* check results:  */
+  for (i = 0; i < 4; i++)
+    {
+      if (C[i] != D[i+3])
+	abort ();
+    }
+
+  return 0;
+}
+
+
+/* The initialization induction loop (with aligned access) is also vectorized.  */
+/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "accesses have the same alignment." 2 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/no-vfa-vect-61.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-61.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-61.c	(revision 0)
@@ -0,0 +1,64 @@
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 256
+
+void bar (float *pa, float *pb, float *pc)
+{
+  int i;
+
+  /* check results:  */
+  for (i = 0; i < N/2; i++)
+    {
+      if (pa[i] != (pb[i+1] * pc[i+1]))
+	abort ();
+    }
+
+  return;
+}
+
+/* Unaligned pointer read accesses with known alignment,
+   and an unaligned write access with unknown alignment.
+   The loop bound is iunknown.
+   Can't prove that the pointers don't alias.
+   vect-57.c is similar to this one with one difference:
+        the loop bound is known.
+   vect-60.c is similar to this one with two differences:
+        aliasing is not a problem, and the write access is unaligned.  */
+
+int
+main1 (int n , float *pa)
+{
+  int i;
+  float b[N] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
+  float c[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+  float *pb = b;
+  float *pc = c;
+
+  for (i = 0; i < n/2; i++)
+    {
+      pa[i] = pb[i+1] * pc[i+1];
+    }
+
+  bar (pa,pb,pc);
+
+  return 0;
+}
+
+int main (void)
+{
+  int i;
+  int n=N;
+  float a[N] __attribute__ ((__aligned__(16)));
+
+  check_vect ();
+  main1 (n,a);
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/vect-49.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-49.c	(revision 127316)
+++ gcc/testsuite/gcc.dg/vect/vect-49.c	(working copy)
@@ -1,61 +0,0 @@
-/* { dg-require-effective-target vect_float } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 256
-
-void bar (float *pa, float *pb, float *pc) 
-{
-  int i;
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    {
-      if (pa[i] != (pb[i] * pc[i]))
-	abort ();
-    }
-
-  return;
-}
-
-/* Unaligned pointer read accesses, aligned pointer write access.
-   The loop bound is known and divisible by the vectorization factor.
-   Can't prove that the pointers don't alias.
-   vect-53.c is similar to this one with one difference:
-        the loop bound is unknown.
-   vect-48.c is similar to this one with one difference:
-        aliasing is not a problem.  */
-
-int
-main1 (float *pb, float *pc)
-{
-  float pa[N] __attribute__ ((__aligned__(16)));
-  int i;
-
-  for (i = 0; i < N; i++)
-    {
-      pa[i] = pb[i] * pc[i];
-    }
-
-  bar (pa,pb,pc);
-
-  return 0;
-}
-
-int main (void)
-{
-  int i;
-  float b[N+1] __attribute__ ((__aligned__(16))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60};
-  float c[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
-
-  check_vect ();
-
-  main1 (b,c);
-  main1 (&b[1],c);
-
-  return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gfortran.dg/vect/pr19049.f90
===================================================================
--- gcc/testsuite/gfortran.dg/vect/pr19049.f90	(revision 127316)
+++ gcc/testsuite/gfortran.dg/vect/pr19049.f90	(working copy)
@@ -1,24 +0,0 @@
-! { dg-do compile }
-! { dg-require-effective-target vect_float }
-
-subroutine s111 (ntimes,ld,n,ctime,dtime,a,b,c,d,e,aa,bb,cc) 
-!     linear dependence testing
-!     no dependence - vectorizable
-!     but not consecutive access
-
-      integer ntimes, ld, n, i, nl
-      real a(n), b(n), c(n), d(n), e(n), aa(ld,n), bb(ld,n), cc(ld,n)
-      real t1, t2, second, chksum, ctime, dtime, cs1d
-      do 1 nl = 1,2*ntimes
-      do 10 i = 2,n,2
-         a(i) = a(i-1) + b(i)
-  10  continue
-      call dummy(ld,n,a,b,c,d,e,aa,bb,cc,1.)
-  1   continue
-      return
-      end
-
-! { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } }
-! { dg-final { scan-tree-dump-times "complicated access pattern" 1 "vect" } }
-! { dg-final { cleanup-tree-dump "vect" } }
-
Index: gcc/testsuite/gfortran.dg/vect/no-vfa-pr19049.f90
===================================================================
--- gcc/testsuite/gfortran.dg/vect/no-vfa-pr19049.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/vect/no-vfa-pr19049.f90	(revision 0)
@@ -0,0 +1,24 @@
+! { dg-do compile }
+! { dg-require-effective-target vect_float }
+
+subroutine s111 (ntimes,ld,n,ctime,dtime,a,b,c,d,e,aa,bb,cc) 
+!     linear dependence testing
+!     no dependence - vectorizable
+!     but not consecutive access
+
+      integer ntimes, ld, n, i, nl
+      real a(n), b(n), c(n), d(n), e(n), aa(ld,n), bb(ld,n), cc(ld,n)
+      real t1, t2, second, chksum, ctime, dtime, cs1d
+      do 1 nl = 1,2*ntimes
+      do 10 i = 2,n,2
+         a(i) = a(i-1) + b(i)
+  10  continue
+      call dummy(ld,n,a,b,c,d,e,aa,bb,cc,1.)
+  1   continue
+      return
+      end
+
+! { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } }
+! { dg-final { scan-tree-dump-times "complicated access pattern" 1 "vect" } }
+! { dg-final { cleanup-tree-dump "vect" } }
+

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-08-19 12:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-14 11:02 [PATCH] [4.3 projects] Verctorizer - versioning for alias Victor Kaplansky
2007-08-14 11:38 ` Zdenek Dvorak
2007-08-14 12:23   ` Victor Kaplansky
2007-08-14 17:07 ` Dorit Nuzman
     [not found] <OF128D770D.7C095078-ONC2257337.00562B23-C2257337.005E3D6E@LocalDomain>
2007-08-16 11:07 ` Victor Kaplansky
2007-08-16 13:09   ` Dorit Nuzman
     [not found] <OF531586B8.1BD86F22-ONC2257339.0046568C-C2257339.00487D11@LocalDomain>
2007-08-16 13:49 ` Victor Kaplansky
     [not found] <OFD8F5F2C8.37DFE3DF-ONC2257339.004A59E3-C2257339.004BD2B1@LocalDomain>
2007-08-18  7:54 ` Dorit Nuzman
2007-08-19  9:20 ` Dorit Nuzman
2007-08-19 15:13 ` Dorit Nuzman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).