2010-10-07 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 7 Oct 2010 14:34:44 +0000 (14:34 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 7 Oct 2010 14:34:44 +0000 (14:34 +0000)
* target.def (units_per_simd_word): Rename to ...
(preferred_simd_mode): ... this.  Return mode instead of size.
* targhooks.c (default_units_per_simd_word): Rename to ...
(default_preferred_simd_mode): ... this.  Return word_mode.
* targhooks.h (default_preferred_simd_mode): Declare.
* config/arm/arm.c (arm_units_per_simd_word): Rename to ...
(arm_preferred_simd_mode): ... this.  Re-implement.
* config/i386/i386.c (ix86_units_per_simd_word): Rename to ...
(ix86_preferred_simd_mode): ... this.  Re-implement.
* config/sparc/sparc.c (sparc_units_per_simd_word): Rename to ...
(sparc_preferred_simd_mode): ... this.  Re-implement.
* config/mips/mips.c (mips_units_per_simd_word): Rename to ...
(mips_preferred_simd_mode): ... this.  Re-implement.
* config/rs6000/rs6000.c (rs6000_units_per_simd_word): Rename to ...
(rs6000_preferred_simd_mode): ... this.  Re-implement.
* tree-vect-stmts.c (get_vectype_for_scalar_type): Adjust.
* doc/tm.texi.in (TARGET_VECTORIZE_UNITS_PER_SIMD_WORD): Remove.
(TARGET_VECTORIZE_PREFERRED_SIMD_MODE): Document.
* doc/tm.texi: Update.

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

12 files changed:
gcc/ChangeLog
gcc/config/arm/arm.c
gcc/config/i386/i386.c
gcc/config/mips/mips.c
gcc/config/rs6000/rs6000.c
gcc/config/sparc/sparc.c
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/target.def
gcc/targhooks.c
gcc/targhooks.h
gcc/tree-vect-stmts.c

index 2768905..20df6bb 100644 (file)
@@ -1,5 +1,27 @@
 2010-10-07  Richard Guenther  <rguenther@suse.de>
 
+       * target.def (units_per_simd_word): Rename to ...
+       (preferred_simd_mode): ... this.  Return mode instead of size.
+       * targhooks.c (default_units_per_simd_word): Rename to ...
+       (default_preferred_simd_mode): ... this.  Return word_mode.
+       * targhooks.h (default_preferred_simd_mode): Declare.
+       * config/arm/arm.c (arm_units_per_simd_word): Rename to ...
+       (arm_preferred_simd_mode): ... this.  Re-implement.
+       * config/i386/i386.c (ix86_units_per_simd_word): Rename to ...
+       (ix86_preferred_simd_mode): ... this.  Re-implement.
+       * config/sparc/sparc.c (sparc_units_per_simd_word): Rename to ...
+       (sparc_preferred_simd_mode): ... this.  Re-implement.
+       * config/mips/mips.c (mips_units_per_simd_word): Rename to ...
+       (mips_preferred_simd_mode): ... this.  Re-implement.
+       * config/rs6000/rs6000.c (rs6000_units_per_simd_word): Rename to ...
+       (rs6000_preferred_simd_mode): ... this.  Re-implement.
+       * tree-vect-stmts.c (get_vectype_for_scalar_type): Adjust.
+       * doc/tm.texi.in (TARGET_VECTORIZE_UNITS_PER_SIMD_WORD): Remove.
+       (TARGET_VECTORIZE_PREFERRED_SIMD_MODE): Document.
+       * doc/tm.texi: Update.
+
+2010-10-07  Richard Guenther  <rguenther@suse.de>
+
        PR middle-end/45869
        * tree-cfg.c (verify_gimple_assign_binary): Allow vector shifts
        of pointers.
index 7a8155d..8ad312e 100644 (file)
@@ -240,7 +240,7 @@ static rtx arm_trampoline_adjust_address (rtx);
 static rtx arm_pic_static_addr (rtx orig, rtx reg);
 static bool cortex_a9_sched_adjust_cost (rtx, rtx, rtx, int *);
 static bool xscale_sched_adjust_cost (rtx, rtx, rtx, int *);
-static unsigned int arm_units_per_simd_word (enum machine_mode);
+static enum machine_mode arm_preferred_simd_mode (enum machine_mode);
 static bool arm_class_likely_spilled_p (reg_class_t);
 static bool arm_vector_alignment_reachable (const_tree type, bool is_packed);
 static bool arm_builtin_support_vector_misalignment (enum machine_mode mode,
@@ -381,8 +381,8 @@ static const struct attribute_spec arm_attribute_table[] =
 #define TARGET_SHIFT_TRUNCATION_MASK arm_shift_truncation_mask
 #undef TARGET_VECTOR_MODE_SUPPORTED_P
 #define TARGET_VECTOR_MODE_SUPPORTED_P arm_vector_mode_supported_p
-#undef TARGET_VECTORIZE_UNITS_PER_SIMD_WORD
-#define TARGET_VECTORIZE_UNITS_PER_SIMD_WORD arm_units_per_simd_word
+#undef TARGET_VECTORIZE_PREFERRED_SIMD_MODE
+#define TARGET_VECTORIZE_PREFERRED_SIMD_MODE arm_preferred_simd_mode
 
 #undef  TARGET_MACHINE_DEPENDENT_REORG
 #define TARGET_MACHINE_DEPENDENT_REORG arm_reorg
@@ -21998,11 +21998,42 @@ arm_vector_mode_supported_p (enum machine_mode mode)
    registers when autovectorizing for Neon, at least until multiple vector
    widths are supported properly by the middle-end.  */
 
-static unsigned int
-arm_units_per_simd_word (enum machine_mode mode ATTRIBUTE_UNUSED)
+static enum machine_mode
+arm_preferred_simd_mode (enum machine_mode mode)
 {
-  return (TARGET_NEON
-         ? (TARGET_NEON_VECTORIZE_QUAD ? 16 : 8) : UNITS_PER_WORD);
+  if (TARGET_NEON)
+    switch (mode)
+      {
+      case SFmode:
+       return TARGET_NEON_VECTORIZE_QUAD ? V4SFmode : V2SFmode;
+      case SImode:
+       return TARGET_NEON_VECTORIZE_QUAD ? V4SImode : V2SImode;
+      case HImode:
+       return TARGET_NEON_VECTORIZE_QUAD ? V8HImode : V4HImode;
+      case QImode:
+       return TARGET_NEON_VECTORIZE_QUAD ? V16QImode : V8QImode;
+      case DImode:
+       if (TARGET_NEON_VECTORIZE_QUAD)
+         return V2DImode;
+       break;
+
+      default:;
+      }
+
+  if (TARGET_REALLY_IWMMXT)
+    switch (mode)
+      {
+      case SImode:
+       return V2SImode;
+      case HImode:
+       return V4HImode;
+      case QImode:
+       return V8QImode;
+
+      default:;
+      }
+
+  return word_mode;
 }
 
 /* Implement TARGET_CLASS_LIKELY_SPILLED_P.
index 7fe654a..74ded78 100644 (file)
@@ -32962,23 +32962,35 @@ has_dispatch (rtx insn, int action)
 /* ??? No autovectorization into MMX or 3DNOW until we can reliably
    place emms and femms instructions.  */
 
-static unsigned int
-ix86_units_per_simd_word (enum machine_mode mode)
+static enum machine_mode
+ix86_preferred_simd_mode (enum machine_mode mode)
 {
   /* Disable double precision vectorizer if needed.  */
   if (mode == DFmode && !TARGET_VECTORIZE_DOUBLE)
-    return UNITS_PER_WORD;
+    return word_mode;
 
-#if 0
-  /*  FIXME: AVX has 32byte floating point vector operations and 16byte
-      integer vector operations.  But vectorizer doesn't support
-      different sizes for integer and floating point vectors.  We limit
-      vector size to 16byte.  */
-  if (TARGET_AVX)
-    return (mode == DFmode || mode == SFmode) ? 32 : 16;
-  else
-#endif
-    return TARGET_SSE ? 16 : UNITS_PER_WORD;
+  if (!TARGET_AVX && !TARGET_SSE)
+    return word_mode;
+
+  switch (mode)
+    {
+    case SFmode:
+      return TARGET_AVX ? V8SFmode : V4SFmode;
+    case DFmode:
+      return TARGET_AVX ? V4DFmode : V2DFmode;
+    case DImode:
+      return V2DImode;
+    case SImode:
+      return V4SImode;
+    case HImode:
+      return V8HImode;
+    case QImode:
+      return V16QImode;
+
+    default:;
+    }
+
+  return word_mode;
 }
 
 /* Initialize the GCC target structure.  */
@@ -33238,9 +33250,9 @@ ix86_units_per_simd_word (enum machine_mode mode)
 #undef TARGET_VECTORIZE_BUILTIN_VEC_PERM_OK
 #define TARGET_VECTORIZE_BUILTIN_VEC_PERM_OK \
   ix86_vectorize_builtin_vec_perm_ok
-#undef TARGET_VECTORIZE_UNITS_PER_SIMD_WORD
-#define TARGET_VECTORIZE_UNITS_PER_SIMD_WORD \
-  ix86_units_per_simd_word
+#undef TARGET_VECTORIZE_PREFERRED_SIMD_MODE
+#define TARGET_VECTORIZE_PREFERRED_SIMD_MODE \
+  ix86_preferred_simd_mode
 
 #undef TARGET_SET_CURRENT_FUNCTION
 #define TARGET_SET_CURRENT_FUNCTION ix86_set_current_function
index 95994cf..6555470 100644 (file)
@@ -11140,12 +11140,15 @@ mips_scalar_mode_supported_p (enum machine_mode mode)
   return default_scalar_mode_supported_p (mode);
 }
 \f
-/* Implement TARGET_VECTORIZE_UNITS_PER_SIMD_WORD.  */
+/* Implement TARGET_VECTORIZE_PREFERRED_SIMD_MODE.  */
 
-static unsigned int
-mips_units_per_simd_word (enum machine_mode mode ATTRIBUTE_UNUSED)
+static enum machine_mode
+mips_preferred_simd_mode (enum machine_mode mode ATTRIBUTE_UNUSED)
 {
-  return TARGET_PAIRED_SINGLE_FLOAT ? 8 : UNITS_PER_WORD;
+  if (TARGET_PAIRED_SINGLE_FLOAT
+      && mode == SFmode)
+    return V2SFmode;
+  return word_mode;
 }
 
 /* Implement TARGET_INIT_LIBFUNCS.  */
@@ -16524,8 +16527,8 @@ mips_shift_truncation_mask (enum machine_mode mode)
 #undef TARGET_SCALAR_MODE_SUPPORTED_P
 #define TARGET_SCALAR_MODE_SUPPORTED_P mips_scalar_mode_supported_p
 
-#undef TARGET_VECTORIZE_UNITS_PER_SIMD_WORD
-#define TARGET_VECTORIZE_UNITS_PER_SIMD_WORD mips_units_per_simd_word
+#undef TARGET_VECTORIZE_PREFERRED_SIMD_MODE
+#define TARGET_VECTORIZE_PREFERRED_SIMD_MODE mips_preferred_simd_mode
 
 #undef TARGET_INIT_BUILTINS
 #define TARGET_INIT_BUILTINS mips_init_builtins
index 509000b..91b2612 100644 (file)
@@ -1086,7 +1086,7 @@ static bool rs6000_builtin_support_vector_misalignment (enum
                                                        int, bool);
 static int rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt,
                                               tree, int);
-static unsigned int rs6000_units_per_simd_word (enum machine_mode);
+static enum machine_mode rs6000_preferred_simd_mode (enum machine_mode);
 
 static void def_builtin (int, const char *, tree, int);
 static bool rs6000_vector_alignment_reachable (const_tree, bool);
@@ -1492,9 +1492,9 @@ static const struct attribute_spec rs6000_attribute_table[] =
 #undef TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST
 #define TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST \
   rs6000_builtin_vectorization_cost
-#undef TARGET_VECTORIZE_UNITS_PER_SIMD_WORD
-#define TARGET_VECTORIZE_UNITS_PER_SIMD_WORD \
-  rs6000_units_per_simd_word
+#undef TARGET_VECTORIZE_PREFERRED_SIMD_MODE
+#define TARGET_VECTORIZE_PREFERRED_SIMD_MODE \
+  rs6000_preferred_simd_mode
 
 #undef TARGET_INIT_BUILTINS
 #define TARGET_INIT_BUILTINS rs6000_init_builtins
@@ -3595,16 +3595,46 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
     }
 }
 
-/* Implement targetm.vectorize.units_per_simd_word.  */
+/* Implement targetm.vectorize.preferred_simd_mode.  */
 
-static unsigned int
-rs6000_units_per_simd_word (enum machine_mode mode ATTRIBUTE_UNUSED)
+static enum machine_mode
+rs6000_preferred_simd_mode (enum machine_mode mode)
 {
-  return (TARGET_VSX ? UNITS_PER_VSX_WORD
-         : (TARGET_ALTIVEC ? UNITS_PER_ALTIVEC_WORD
-            : (TARGET_SPE ? UNITS_PER_SPE_WORD
-               : (TARGET_PAIRED_FLOAT ? UNITS_PER_PAIRED_WORD
-                  : UNITS_PER_WORD))));
+  if (TARGET_VSX)
+    switch (mode)
+      {
+      case DFmode:
+       return V2DFmode;
+      default:;
+      }
+  if (TARGET_ALTIVEC || TARGET_VSX)
+    switch (mode)
+      {
+      case SFmode:
+       return V4SFmode;
+      case DImode:
+       return V2DImode;
+      case SImode:
+       return V4SImode;
+      case HImode:
+       return V8HImode;
+      case QImode:
+       return V16QImode;
+      default:;
+      }
+  if (TARGET_SPE)
+    switch (mode)
+      {
+      case SFmode:
+       return V2SFmode;
+      case SImode:
+       return V2SImode;
+      default:;
+      }
+  if (TARGET_PAIRED_FLOAT
+      && mode == SFmode)
+    return V2SFmode;
+  return word_mode;
 }
 
 /* Handle generic options of the form -mfoo=yes/no.
index 36c6053..d672d8f 100644 (file)
@@ -435,7 +435,7 @@ static bool sparc_can_eliminate (const int, const int);
 static const char *sparc_mangle_type (const_tree);
 #endif
 static void sparc_trampoline_init (rtx, tree, rtx);
-static unsigned int sparc_units_per_simd_word (enum machine_mode);
+static enum machine_mode sparc_preferred_simd_mode (enum machine_mode);
 \f
 #ifdef SUBTARGET_ATTRIBUTE_TABLE
 /* Table of valid machine attributes.  */
@@ -573,8 +573,8 @@ static bool fpu_option_set = false;
 #undef TARGET_VECTOR_MODE_SUPPORTED_P
 #define TARGET_VECTOR_MODE_SUPPORTED_P sparc_vector_mode_supported_p
 
-#undef TARGET_VECTORIZE_UNITS_PER_SIMD_WORD
-#define TARGET_VECTORIZE_UNITS_PER_SIMD_WORD sparc_units_per_simd_word
+#undef TARGET_VECTORIZE_PREFERRED_SIMD_MODE
+#define TARGET_VECTORIZE_PREFERRED_SIMD_MODE sparc_preferred_simd_mode
 
 #undef TARGET_DWARF_HANDLE_FRAME_UNSPEC
 #define TARGET_DWARF_HANDLE_FRAME_UNSPEC sparc_dwarf_handle_frame_unspec
@@ -6244,12 +6244,25 @@ sparc_vector_mode_supported_p (enum machine_mode mode)
   return TARGET_VIS && VECTOR_MODE_P (mode) ? true : false;
 }
 \f
-/* Implement the TARGET_VECTORIZE_UNITS_PER_SIMD_WORD target hook.  */
+/* Implement the TARGET_VECTORIZE_PREFERRED_SIMD_MODE target hook.  */
 
-static unsigned int
-sparc_units_per_simd_word (enum machine_mode mode ATTRIBUTE_UNUSED)
+static enum machine_mode
+sparc_preferred_simd_mode (enum machine_mode mode)
 {
-  return TARGET_VIS ? 8 : UNITS_PER_WORD;
+  if (TARGET_VIS)
+    switch (mode)
+      {
+      case SImode:
+       return V2SImode;
+      case HImode:
+       return V4HImode;
+      case QImode:
+       return V8QImode;
+
+      default:;
+      }
+
+  return word_mode;
 }
 \f
 /* Return the string to output an unconditional branch to LABEL, which is
index c686cbc..afa1971 100644 (file)
@@ -5743,10 +5743,10 @@ the elements in the vectors should be of type @var{type}.  @var{is_packed}
 parameter is true if the memory access is defined in a packed struct.
 @end deftypefn
 
-@deftypefn {Target Hook} {unsigned int} TARGET_VECTORIZE_UNITS_PER_SIMD_WORD (enum machine_mode @var{mode})
-This hook should return th number of units in the vectors that the
-vectorizer can produce for scalar mode @var{mode}.  The default is
-equal to @code{UNITS_PER_WORD}, because the vectorizer can do some
+@deftypefn {Target Hook} {enum machine_mode} TARGET_VECTORIZE_PREFERRED_SIMD_MODE (enum machine_mode @var{mode})
+This hook should return the preferred mode for vectorizing scalar
+mode @var{mode}.  The default is
+equal to @code{word_mode}, because the vectorizer can do some
 transformations even in absence of specialized @acronym{SIMD} hardware.
 @end deftypefn
 
index 4c43fd5..8489027 100644 (file)
@@ -5741,10 +5741,10 @@ the elements in the vectors should be of type @var{type}.  @var{is_packed}
 parameter is true if the memory access is defined in a packed struct.
 @end deftypefn
 
-@hook TARGET_VECTORIZE_UNITS_PER_SIMD_WORD
-This hook should return th number of units in the vectors that the
-vectorizer can produce for scalar mode @var{mode}.  The default is
-equal to @code{UNITS_PER_WORD}, because the vectorizer can do some
+@hook TARGET_VECTORIZE_PREFERRED_SIMD_MODE
+This hook should return the preferred mode for vectorizing scalar
+mode @var{mode}.  The default is
+equal to @code{word_mode}, because the vectorizer can do some
 transformations even in absence of specialized @acronym{SIMD} hardware.
 @end deftypefn
 
index 7a07f09..f104ae8 100644 (file)
@@ -880,13 +880,14 @@ DEFHOOK
  (enum machine_mode mode, const_tree type, int misalignment, bool is_packed),
  default_builtin_support_vector_misalignment)
 
-/* Return units per SIMD word.  */
+/* Returns the preferred mode for SIMD operations for the specified
+   scalar mode.  */
 DEFHOOK
-(units_per_simd_word,
+(preferred_simd_mode,
  "",
unsigned int,
enum machine_mode,
  (enum machine_mode mode),
- default_units_per_simd_word)
+ default_preferred_simd_mode)
 
 HOOK_VECTOR_END (vectorize)
 
index 5a36f0e..0a65b2a 100644 (file)
@@ -979,10 +979,10 @@ default_builtin_support_vector_misalignment (enum machine_mode mode,
 /* By default, only attempt to parallelize bitwise operations, and
    possibly adds/subtracts using bit-twiddling.  */
 
-unsigned int
-default_units_per_simd_word (enum machine_mode mode ATTRIBUTE_UNUSED)
+enum machine_mode
+default_preferred_simd_mode (enum machine_mode mode ATTRIBUTE_UNUSED)
 {
-  return UNITS_PER_WORD;
+  return word_mode;
 }
 
 /* Determine whether or not a pointer mode is valid. Assume defaults
index da575f3..a705d7e 100644 (file)
@@ -86,7 +86,7 @@ extern bool
 default_builtin_support_vector_misalignment (enum machine_mode mode,
                                             const_tree,
                                             int, bool);
-extern unsigned int default_units_per_simd_word (enum machine_mode mode);
+extern enum machine_mode default_preferred_simd_mode (enum machine_mode mode);
 
 /* These are here, and not in hooks.[ch], because not all users of
    hooks.h include tm.h, and thus we don't have CUMULATIVE_ARGS.  */
index b120dc6..8fba200 100644 (file)
@@ -4793,12 +4793,12 @@ tree
 get_vectype_for_scalar_type (tree scalar_type)
 {
   enum machine_mode inner_mode = TYPE_MODE (scalar_type);
+  enum machine_mode simd_mode;
   unsigned int nbytes = GET_MODE_SIZE (inner_mode);
   int nunits;
   tree vectype;
 
-  if (nbytes == 0
-      || (nbytes >= targetm.vectorize.units_per_simd_word (inner_mode)))
+  if (nbytes == 0)
     return NULL_TREE;
 
   /* We can't build a vector type of elements with alignment bigger than
@@ -4814,9 +4814,14 @@ get_vectype_for_scalar_type (tree scalar_type)
       && GET_MODE_BITSIZE (inner_mode) != TYPE_PRECISION (scalar_type))
     return NULL_TREE;
 
-  /* FORNOW: Only a single vector size per mode
-    (TARGET_VECTORIZE_UNITS_PER_SIMD_WORD) is expected.  */
-  nunits = targetm.vectorize.units_per_simd_word (inner_mode) / nbytes;
+  if (GET_MODE_CLASS (inner_mode) != MODE_INT
+      && GET_MODE_CLASS (inner_mode) != MODE_FLOAT)
+    return NULL_TREE;
+
+  simd_mode = targetm.vectorize.preferred_simd_mode (inner_mode);
+  nunits = GET_MODE_SIZE (simd_mode) / nbytes;
+  if (nunits <= 1)
+    return NULL_TREE;
 
   vectype = build_vector_type (scalar_type, nunits);
   if (vect_print_dump_info (REPORT_DETAILS))