summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-07 14:34:44 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-07 14:34:44 +0000
commitb24d851fa7cad44fd130f4386f28062d6c395bb1 (patch)
treee369542c279196e8b7be20440bc887cf9eed16f3
parent0d82568791b8565cc38d03ac20a63863cc74f1fb (diff)
downloadgcc-b24d851fa7cad44fd130f4386f28062d6c395bb1.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165114 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog22
-rw-r--r--gcc/config/arm/arm.c45
-rw-r--r--gcc/config/i386/i386.c44
-rw-r--r--gcc/config/mips/mips.c15
-rw-r--r--gcc/config/rs6000/rs6000.c54
-rw-r--r--gcc/config/sparc/sparc.c27
-rw-r--r--gcc/doc/tm.texi8
-rw-r--r--gcc/doc/tm.texi.in8
-rw-r--r--gcc/target.def9
-rw-r--r--gcc/targhooks.c6
-rw-r--r--gcc/targhooks.h2
-rw-r--r--gcc/tree-vect-stmts.c15
12 files changed, 186 insertions, 69 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2768905ea87..20df6bb94b2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 7a8155d2fbc..8ad312ed743 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -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.
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 7fe654a3586..74ded78f800 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -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
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 95994cfc7a9..6555470dca3 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -11140,12 +11140,15 @@ mips_scalar_mode_supported_p (enum machine_mode mode)
return default_scalar_mode_supported_p (mode);
}
-/* 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
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 509000ba822..91b26124c5c 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -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.
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 36c60533d98..d672d8f6e3e 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -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);
#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;
}
-/* 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;
}
/* Return the string to output an unconditional branch to LABEL, which is
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index c686cbc99db..afa1971695e 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -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
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 4c43fd535e8..8489027e41b 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -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
diff --git a/gcc/target.def b/gcc/target.def
index 7a07f097b3f..f104ae8069e 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -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)
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index 5a36f0eadfc..0a65b2acc92 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -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
diff --git a/gcc/targhooks.h b/gcc/targhooks.h
index da575f3e7e0..a705d7e8586 100644
--- a/gcc/targhooks.h
+++ b/gcc/targhooks.h
@@ -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. */
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index b120dc60961..8fba200f874 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -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))