]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR testsuite/49443 (gcc.dg/vect/vect-peel-3.c and vect-peel-4.c fail...
authorUlrich Weigand <ulrich.weigand@linaro.org>
Fri, 10 Aug 2012 13:26:44 +0000 (13:26 +0000)
committerUlrich Weigand <uweigand@gcc.gnu.org>
Fri, 10 Aug 2012 13:26:44 +0000 (13:26 +0000)
ChangeLog:

Backport from mainline
2012-07-30  Ulrich Weigand  <ulrich.weigand@linaro.org>
    Richard Earnshaw  <rearnsha@arm.com>

* target.def (vector_alignment): New target hook.
* doc/tm.texi.in (TARGET_VECTOR_ALIGNMENT): Document new hook.
* doc/tm.texi: Regenerate.
* targhooks.c (default_vector_alignment): New function.
* targhooks.h (default_vector_alignment): Add prototype.
* stor-layout.c (layout_type): Use targetm.vector_alignment.
* config/arm/arm.c (arm_vector_alignment): New function.
(TARGET_VECTOR_ALIGNMENT): Define.

* tree-vect-data-refs.c (vect_update_misalignment_for_peel): Use
vector type alignment instead of size.
* tree-vect-loop-manip.c (vect_do_peeling_for_loop_bound): Use
element type size directly instead of computing it from alignment.
Fix variable naming and comment.

testsuite/ChangeLog:

Backport from mainline
2012-07-30  Ulrich Weigand  <ulrich.weigand@linaro.org>

* lib/target-supports.exp
(check_effective_target_vect_natural_alignment): New function.
* gcc.dg/align-2.c: Only run on targets with natural alignment
of vector types.
* gcc.dg/vect/slp-25.c: Adjust tests for targets without natural
alignment of vector types.

2011-12-21  Michael Zolotukhin  <michael.v.zolotukhin@intel.com>

* gcc.dg/vect/vect-peel-1.c: Adjust test diag-scans to fix fail on AVX.
* gcc.dg/vect/vect-peel-2.c: Ditto.

2011-06-21  Ira Rosen  <ira.rosen@linaro.org>

PR testsuite/49443
* gcc.dg/vect/vect-peel-3.c: Expect to fail on vect_no_align
targets.
* gcc.dg/vect/vect-peel-4.c: Likewise.

2011-06-14  Ira Rosen  <ira.rosen@linaro.org>

* gcc.dg/vect/vect-peel-3.c: Adjust misalignment values
for double-word vectors.
* gcc.dg/vect/vect-peel-4.c: Likewise.

From-SVN: r190296

18 files changed:
gcc/ChangeLog
gcc/config/arm/arm.c
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/stor-layout.c
gcc/target.def
gcc/targhooks.c
gcc/targhooks.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/align-2.c
gcc/testsuite/gcc.dg/vect/slp-25.c
gcc/testsuite/gcc.dg/vect/vect-peel-1.c
gcc/testsuite/gcc.dg/vect/vect-peel-2.c
gcc/testsuite/gcc.dg/vect/vect-peel-3.c
gcc/testsuite/gcc.dg/vect/vect-peel-4.c
gcc/testsuite/lib/target-supports.exp
gcc/tree-vect-data-refs.c
gcc/tree-vect-loop-manip.c

index f9790d4aee690ddba7fe9d04ebd4ce5af87536c5..574c3a5ab20e22ddb687001d99390fc30ae9a10b 100644 (file)
@@ -1,3 +1,24 @@
+2012-08-10  Ulrich Weigand  <ulrich.weigand@linaro.org>
+
+       Backport from mainline
+       2012-07-30  Ulrich Weigand  <ulrich.weigand@linaro.org>
+                   Richard Earnshaw  <rearnsha@arm.com>
+
+       * target.def (vector_alignment): New target hook.
+       * doc/tm.texi.in (TARGET_VECTOR_ALIGNMENT): Document new hook.
+       * doc/tm.texi: Regenerate.
+       * targhooks.c (default_vector_alignment): New function.
+       * targhooks.h (default_vector_alignment): Add prototype.
+       * stor-layout.c (layout_type): Use targetm.vector_alignment.
+       * config/arm/arm.c (arm_vector_alignment): New function.
+       (TARGET_VECTOR_ALIGNMENT): Define.
+
+       * tree-vect-data-refs.c (vect_update_misalignment_for_peel): Use
+       vector type alignment instead of size.
+       * tree-vect-loop-manip.c (vect_do_peeling_for_loop_bound): Use
+       element type size directly instead of computing it from alignment.
+       Fix variable naming and comment.
+
 2012-08-09  Uros Bizjak  <ubizjak@gmail.com>
 
        Backport from mainline
index db2d723ba976747b57a986853fb44c2538f12397..f189511f734ef8e1a781b78485fabf05fcd3f2f5 100644 (file)
@@ -243,6 +243,7 @@ static bool xscale_sched_adjust_cost (rtx, rtx, rtx, int *);
 static bool fa726te_sched_adjust_cost (rtx, rtx, rtx, int *);
 static enum machine_mode arm_preferred_simd_mode (enum machine_mode);
 static bool arm_class_likely_spilled_p (reg_class_t);
+static HOST_WIDE_INT arm_vector_alignment (const_tree type);
 static bool arm_vector_alignment_reachable (const_tree type, bool is_packed);
 static bool arm_builtin_support_vector_misalignment (enum machine_mode mode,
                                                     const_tree type,
@@ -579,6 +580,9 @@ static const struct default_options arm_option_optimization_table[] =
 #undef TARGET_CLASS_LIKELY_SPILLED_P
 #define TARGET_CLASS_LIKELY_SPILLED_P arm_class_likely_spilled_p
 
+#undef TARGET_VECTOR_ALIGNMENT
+#define TARGET_VECTOR_ALIGNMENT arm_vector_alignment
+
 #undef TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE
 #define TARGET_VECTORIZE_VECTOR_ALIGNMENT_REACHABLE \
   arm_vector_alignment_reachable
@@ -4693,6 +4697,18 @@ arm_function_arg (CUMULATIVE_ARGS *pcum, enum machine_mode mode,
   return gen_rtx_REG (mode, pcum->nregs);
 }
 
+/* The AAPCS sets the maximum alignment of a vector to 64 bits.  */
+static HOST_WIDE_INT
+arm_vector_alignment (const_tree type)
+{
+  HOST_WIDE_INT align = tree_low_cst (TYPE_SIZE (type), 0);
+
+  if (TARGET_AAPCS_BASED)
+    align = MIN (align, 64);
+
+  return align;
+}
+
 static unsigned int
 arm_function_arg_boundary (enum machine_mode mode, const_tree type)
 {
index f7c0cce85be8adf3d6178d85bc2d0e1eee5205a6..aacd8a6cc1243cc856b360d92fbba5eef6be4101 100644 (file)
@@ -1118,6 +1118,14 @@ make it all fit in fewer cache lines.
 If the value of this macro has a type, it should be an unsigned type.
 @end defmac
 
+@deftypefn {Target Hook} HOST_WIDE_INT TARGET_VECTOR_ALIGNMENT (const_tree @var{type})
+This hook can be used to define the alignment for a vector of type
+@var{type}, in order to comply with a platform ABI.  The default is to
+require natural alignment for vector types.  The alignment returned by
+this hook must be a power-of-two multiple of the default alignment of
+the vector element type.
+@end deftypefn
+
 @defmac STACK_SLOT_ALIGNMENT (@var{type}, @var{mode}, @var{basic-align})
 If defined, a C expression to compute the alignment for stack slot.
 @var{type} is the data type, @var{mode} is the widest mode available,
index 40acf658c616ac472e54d6d6547e0f348fe70eff..919e7673b10ed132fa24da6af88ea2ccdd65262b 100644 (file)
@@ -1108,6 +1108,8 @@ make it all fit in fewer cache lines.
 If the value of this macro has a type, it should be an unsigned type.
 @end defmac
 
+@hook TARGET_VECTOR_ALIGNMENT
+
 @defmac STACK_SLOT_ALIGNMENT (@var{type}, @var{mode}, @var{basic-align})
 If defined, a C expression to compute the alignment for stack slot.
 @var{type} is the data type, @var{mode} is the widest mode available,
index 4e7454d3aea832240005873f2fe983fa99e33165..e6d04e540b5a03ef288199169a491ce653d6be1f 100644 (file)
@@ -1927,9 +1927,17 @@ layout_type (tree type)
        TYPE_SIZE (type) = int_const_binop (MULT_EXPR, TYPE_SIZE (innertype),
                                            bitsize_int (nunits), 0);
 
-       /* Always naturally align vectors.  This prevents ABI changes
-          depending on whether or not native vector modes are supported.  */
-       TYPE_ALIGN (type) = tree_low_cst (TYPE_SIZE (type), 0);
+       /* For vector types, we do not default to the mode's alignment.
+          Instead, query a target hook, defaulting to natural alignment.
+          This prevents ABI changes depending on whether or not native
+          vector modes are supported.  */
+       TYPE_ALIGN (type) = targetm.vector_alignment (type);
+
+       /* However, if the underlying mode requires a bigger alignment than
+          what the target hook provides, we cannot use the mode.  For now,
+          simply reject that case.  */
+       gcc_assert (TYPE_ALIGN (type)
+                   >= GET_MODE_ALIGNMENT (TYPE_MODE (type)));
         break;
       }
 
index ecacd44cce72194fea7df46316aa723c8c8c7177..6a3490444d89ed97c464baaff7300754ec1f5ad8 100644 (file)
@@ -1611,6 +1611,16 @@ DEFHOOK
  bool, (enum machine_mode mode),
  hook_bool_mode_false)
 
+DEFHOOK
+(vector_alignment,
+ "This hook can be used to define the alignment for a vector of type\n\
+@var{type}, in order to comply with a platform ABI.  The default is to\n\
+require natural alignment for vector types.  The alignment returned by\n\
+this hook must be a power-of-two multiple of the default alignment of\n\
+the vector element type.",
+ HOST_WIDE_INT, (const_tree type),
+ default_vector_alignment)
+
 /* Compute cost of moving data from a register of class FROM to one of
    TO, using MODE.  */
 DEFHOOK
index c1bd118179ca246f2ba226ba72ad968cbc0eb19e..b751f64b9879f5b104458234df8997390db36cac 100644 (file)
@@ -979,6 +979,13 @@ tree default_mangle_decl_assembler_name (tree decl ATTRIBUTE_UNUSED,
    return id;
 }
 
+/* Default to natural alignment for vector types.  */
+HOST_WIDE_INT
+default_vector_alignment (const_tree type)
+{
+  return tree_low_cst (TYPE_SIZE (type), 0);
+}
+
 bool
 default_builtin_vector_alignment_reachable (const_tree type, bool is_packed)
 {
index a8dbb11e716e2dcafaf8ec8ae49221ac41f809d9..40ea3b32d0c6f4fc492c0d1aec3337155425b01b 100644 (file)
@@ -85,6 +85,8 @@ extern int default_builtin_vectorization_cost (enum vect_cost_for_stmt, tree, in
 
 extern tree default_builtin_reciprocal (unsigned int, bool, bool);
 
+extern HOST_WIDE_INT default_vector_alignment (const_tree);
+
 extern bool default_builtin_vector_alignment_reachable (const_tree, bool);
 extern bool
 default_builtin_support_vector_misalignment (enum machine_mode mode,
index 960c35146418c8b6b9c6451a1f8dad459da16e9e..29ae25cac8b4f3499a9773a049b86207ac762340 100644 (file)
@@ -1,3 +1,33 @@
+2012-08-10  Ulrich Weigand  <ulrich.weigand@linaro.org>
+
+       Backport from mainline
+       2012-07-30  Ulrich Weigand  <ulrich.weigand@linaro.org>
+
+       * lib/target-supports.exp
+       (check_effective_target_vect_natural_alignment): New function.
+       * gcc.dg/align-2.c: Only run on targets with natural alignment
+       of vector types.
+       * gcc.dg/vect/slp-25.c: Adjust tests for targets without natural
+       alignment of vector types.
+
+       2011-12-21  Michael Zolotukhin  <michael.v.zolotukhin@intel.com>
+
+       * gcc.dg/vect/vect-peel-1.c: Adjust test diag-scans to fix fail on AVX.
+       * gcc.dg/vect/vect-peel-2.c: Ditto.
+
+       2011-06-21  Ira Rosen  <ira.rosen@linaro.org>
+
+       PR testsuite/49443
+       * gcc.dg/vect/vect-peel-3.c: Expect to fail on vect_no_align
+       targets.
+       * gcc.dg/vect/vect-peel-4.c: Likewise.
+
+       2011-06-14  Ira Rosen  <ira.rosen@linaro.org>
+
+       * gcc.dg/vect/vect-peel-3.c: Adjust misalignment values
+       for double-word vectors.
+       * gcc.dg/vect/vect-peel-4.c: Likewise.
+
 2012-08-06  Anna Tikhonova  <anna.m.tikhonova@gmail.com>
 
        * gcc.dg/20020201-1.c: Remove declarations for exit, abort,
index f5c00fd0c6527fbaa25df41ea2356cf0ac057f9f..2001a153bac47dc58f43769ed27a7f1c14b56710 100644 (file)
@@ -1,5 +1,5 @@
 /* PR 17962 */
-/* { dg-do compile } */
+/* { dg-do compile { target vect_natural_alignment } } */
 /* { dg-options "" } */
 
 typedef float v4 __attribute__((vector_size(sizeof(float)*4)));
index 45176398834649d0d0c1d083c64c0b0f3c14d38f..497563703cfe906252025ae234b7a75e7297998e 100644 (file)
@@ -57,5 +57,5 @@ int main (void)
 
 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect"  } } */
 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { xfail { vect_no_align } } } } */
+/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { xfail { vect_no_align || { ! vect_natural_alignment } } } } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
index 58a0cdbf203bdc497079c43dbb5d167f14034446..8aca27ca1742719126a3ff5cca6a5e2752a45628 100644 (file)
@@ -49,6 +49,6 @@ int main (void)
 }
 
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
-/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target vect_element_align } } } */
+/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target { { vect_element_align } && { vect_aligned_arrays } } } } } */
 /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
index 126c2cf1139131535722eea55411c39d277f6002..f6942d45888d87369f99fd2661509417d6df2270 100644 (file)
@@ -50,6 +50,6 @@ int main (void)
 }
 
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
-/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target vect_element_align } } } */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { target vect_element_align } } } */
+/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target { { vect_element_align } && { vect_aligned_arrays } } } } } */
+/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { target { { vect_element_align } && { vect_aligned_arrays } } } } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
index bc8adb4600856659e260680d4ba9963eaaf02747..8f4d3571494cf29d9ef9a9f9fba46f9faaddc805 100644 (file)
@@ -4,9 +4,7 @@
 #include "tree-vect.h"
 
 #define N 128
-#define RES 21888 
-
-/* unaligned store.  */
+#define RES 21640 
 
 int ib[N+10];
 int ia[N+10];
@@ -18,11 +16,11 @@ int main1 ()
   int i, suma = 0, sumb = 0, sumc = 0;
 
   /* ib and ic have same misalignment, we peel to align them.  */
-  for (i = 1; i <= N; i++)
+  for (i = 0; i <= N; i++)
     {
       suma += ia[i];
-      sumb += ib[i+6];
-      sumc += ic[i+2];
+      sumb += ib[i+5];
+      sumc += ic[i+1];
     }
 
   /* check results:  */
@@ -49,7 +47,7 @@ int main (void)
   return main1 ();
 }
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail vect_no_align } } } */
 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect"  { xfail vect_no_align } } } */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_no_align } } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
index a71d4c4eba0f94f778b90738f8879cb7109d943c..1b47f2682bb9e0decd7b9053bfc2a9281be61878 100644 (file)
@@ -16,13 +16,13 @@ int main1 ()
   /* Don't peel keeping one load and the store aligned.  */
   for (i = 0; i <= N; i++)
     {
-      ia[i] = ib[i] + ib[i+6];
+      ia[i] = ib[i] + ib[i+5];
     }
 
   /* check results:  */
   for (i = 1; i <= N; i++)
     {
-      if (ia[i] != ib[i] + ib[i+6])
+      if (ia[i] != ib[i] + ib[i+5])
         abort ();
     }
 
@@ -44,7 +44,7 @@ int main (void)
   return main1 ();
 }
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail vect_no_align } } } */
 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect"  { xfail vect_no_align } } } */
 /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
index 788a51205b8e8106fc642fb3c2f8341b8f651adf..7da4afd8f0ffb0adc7ac3bbb813cbeb44f471fc0 100644 (file)
@@ -2976,6 +2976,26 @@ proc check_effective_target_natural_alignment_64 { } {
     return $et_natural_alignment_64_saved
 }
 
+# Return 1 if all vector types are naturally aligned (aligned to their
+# type-size), 0 otherwise.
+#
+# This won't change for different subtargets so cache the result.
+
+proc check_effective_target_vect_natural_alignment { } {
+    global et_vect_natural_alignment
+
+    if [info exists et_vect_natural_alignment_saved] {
+        verbose "check_effective_target_vect_natural_alignment: using cached result" 2
+    } else {
+        set et_vect_natural_alignment_saved 1
+        if { [check_effective_target_arm_eabi] } {
+            set et_vect_natural_alignment_saved 0
+        }
+    }
+    verbose "check_effective_target_vect_natural_alignment: returning $et_vect_natural_alignment_saved" 2
+    return $et_vect_natural_alignment_saved
+}
+
 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
 #
 # This won't change for different subtargets so cache the result.
index d49393f1e435b2b82a1082776eec0e48c77b009f..83482870939c18f25ef4f77900919448c56d420d 100644 (file)
@@ -1019,7 +1019,7 @@ vect_update_misalignment_for_peel (struct data_reference *dr,
       int misal = DR_MISALIGNMENT (dr);
       tree vectype = STMT_VINFO_VECTYPE (stmt_info);
       misal += negative ? -npeel * dr_size : npeel * dr_size;
-      misal &= GET_MODE_SIZE (TYPE_MODE (vectype)) - 1;
+      misal &= (TYPE_ALIGN (vectype) / BITS_PER_UNIT) - 1;
       SET_DR_MISALIGNMENT (dr, misal);
       return;
     }
index da2c9b75869483eb5508bb14a2a85a5ce565af2a..6ab542e9d4c3ac59f76862032f51ec5ce60d32d9 100644 (file)
@@ -2008,7 +2008,7 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop_vinfo, tree *ratio,
    If the misalignment of DR is known at compile time:
      addr_mis = int mis = DR_MISALIGNMENT (dr);
    Else, compute address misalignment in bytes:
-     addr_mis = addr & (vectype_size - 1)
+     addr_mis = addr & (vectype_align - 1)
 
    prolog_niters = min (LOOP_NITERS, ((VF - addr_mis/elem_size)&(VF-1))/step)
 
@@ -2065,9 +2065,10 @@ vect_gen_niters_for_prolog_loop (loop_vec_info loop_vinfo, tree loop_niters,
       tree ptr_type = TREE_TYPE (start_addr);
       tree size = TYPE_SIZE (ptr_type);
       tree type = lang_hooks.types.type_for_size (tree_low_cst (size, 1), 1);
-      tree vectype_size_minus_1 = build_int_cst (type, vectype_align - 1);
-      tree elem_size_log =
-        build_int_cst (type, exact_log2 (vectype_align/nelements));
+      tree vectype_align_minus_1 = build_int_cst (type, vectype_align - 1);
+      HOST_WIDE_INT elem_size =
+               int_cst_value (TYPE_SIZE_UNIT (TREE_TYPE (vectype)));
+      tree elem_size_log = build_int_cst (type, exact_log2 (elem_size));
       tree nelements_minus_1 = build_int_cst (type, nelements - 1);
       tree nelements_tree = build_int_cst (type, nelements);
       tree byte_misalign;
@@ -2076,10 +2077,10 @@ vect_gen_niters_for_prolog_loop (loop_vec_info loop_vinfo, tree loop_niters,
       new_bb = gsi_insert_seq_on_edge_immediate (pe, new_stmts);
       gcc_assert (!new_bb);
 
-      /* Create:  byte_misalign = addr & (vectype_size - 1)  */
+      /* Create:  byte_misalign = addr & (vectype_align - 1)  */
       byte_misalign =
         fold_build2 (BIT_AND_EXPR, type, fold_convert (type, start_addr), 
-                     vectype_size_minus_1);
+                     vectype_align_minus_1);
 
       /* Create:  elem_misalign = byte_misalign / element_size  */
       elem_misalign =