This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Generic vectorization 2/3
- From: Paolo Bonzini <bonzini at gnu dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 06 Apr 2005 14:04:15 +0200
- Subject: [PATCH] Generic vectorization 2/3
This patch eliminates the special case UNITS_PER_SIMD_WORD == 0 from the
vectorizer. The default is now UNITS_PER_WORD, which means that targets
like alpha, bfin, or ia64 need not define UNITS_PER_SIMD_WORD at all.
On targets that do not support vector modes, vectorization will still
fail of course.
I'm adding a comment to UNITS_PER_SIMD_WORD in defaults.h ("Use
UNITS_PER_WORD to attempt vectorization of bitwise operations, and
possibly adds/subtracts using bit-twiddling"); it is not yet applicable.
Bootstrapped/regtested with the other patches in the series on
powerpc-apple-darwin, ok for mainline?
Paolo
2005-04-06 Paolo Bonzini <bonzini@gnu.org>
* defaults.h (UNITS_PER_SIMD_WORD): Default to UNITS_PER_WORD.
* tree-vect-analyze.c (vect_enhance_data_refs_alignment):
Do not cope with UNITS_PER_SIMD_WORD == 0.
* tree-vect-analyze.c (get_vectype_for_scalar_type): Check
if the scalar type is not bigger than UNITS_PER_SIMD_WORD.
(vectorize_loops): Do not check that UNITS_PER_SIMD_WORD > 0.
* config/i386/i386.h (UNITS_PER_SIMD_WORD): Default to UNITS_PER_WORD.
* config/mips/mips.h (UNITS_PER_SIMD_WORD): Likewise.
* config/rs6000/rs6000.h (UNITS_PER_SIMD_WORD): Likewise.
* config/sparc/sparc.h (UNITS_PER_SIMD_WORD): Likewise.
* config/alpha/alpha.h (UNITS_PER_SIMD_WORD): Remove.
* config/bfin/bfin.h (UNITS_PER_SIMD_WORD): Remove.
* config/ia64/ia64.h (UNITS_PER_SIMD_WORD): Remove.
Index: defaults.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/defaults.h,v
retrieving revision 1.169
diff -p -u -r1.169 defaults.h
--- defaults.h 24 Feb 2005 21:47:19 -0000 1.169
+++ defaults.h 6 Apr 2005 08:35:47 -0000
@@ -702,8 +702,10 @@ do { fputs (integer_asm_op (POINTER_SIZE
#define HAS_LONG_UNCOND_BRANCH 0
#endif
+/* Use UNITS_PER_WORD to attempt vectorization of bitwise operations, and
+ possibly adds/subtracts using bit-twiddling. */
#ifndef UNITS_PER_SIMD_WORD
-#define UNITS_PER_SIMD_WORD 0
+#define UNITS_PER_SIMD_WORD UNITS_PER_WORD
#endif
/* Determine whether __cxa_atexit, rather than atexit, is used to
Index: tree-vect-analyze.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-vect-analyze.c,v
retrieving revision 2.17
diff -p -u -u -r2.17 tree-vect-analyze.c
--- tree-vect-analyze.c 6 Apr 2005 07:59:01 -0000 2.17
+++ tree-vect-analyze.c 6 Apr 2005 08:30:27 -0000
@@ -1014,13 +1015,6 @@ vect_enhance_data_refs_alignment (loop_v
struct data_reference *dr0 = NULL;
unsigned int i, j;
- /* Sigh, a hack to make targets that do not define UNITS_PER_SIMD_WORD
- bootstrap. Copy UNITS_PER_SIMD_WORD to a local variable to avoid a
- "division by zero" error. This error would be issued because we
- we do "... % UNITS_PER_SIMD_WORD" below, and UNITS_PER_SIMD_WORD
- defaults to 0 if it is not defined by the target. */
- int units_per_simd_word = UNITS_PER_SIMD_WORD;
-
/*
This pass will require a cost model to guide it whether to apply peeling
or versioning or a combination of the two. For example, the scheme that
@@ -1175,7 +1169,7 @@ vect_enhance_data_refs_alignment (loop_v
int drsize = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (DR_REF (dr))));
DR_MISALIGNMENT (dr) += npeel * drsize;
- DR_MISALIGNMENT (dr) %= units_per_simd_word;
+ DR_MISALIGNMENT (dr) %= UNITS_PER_SIMD_WORD;
}
else
DR_MISALIGNMENT (dr) = -1;
Index: tree-vectorizer.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-vectorizer.c,v
retrieving revision 2.84
diff -p -u -u -r2.84 tree-vectorizer.c
--- tree-vectorizer.c 5 Apr 2005 19:05:16 -0000 2.84
+++ tree-vectorizer.c 6 Apr 2005 08:30:29 -0000
@@ -1619,7 +1619,7 @@ get_vectype_for_scalar_type (tree scalar
int nunits;
tree vectype;
- if (nbytes == 0)
+ if (nbytes == 0 || nbytes >= UNITS_PER_SIMD_WORD)
return NULL_TREE;
/* FORNOW: Only a single vector size per target (UNITS_PER_SIMD_WORD)
@@ -1827,15 +1822,6 @@ vectorize_loops (struct loops *loops)
/* Fix the verbosity level if not defined explicitly by the user. */
vect_set_dump_settings ();
- /* Does the target support SIMD? */
- /* FORNOW: until more sophisticated machine modelling is in place. */
- if (!UNITS_PER_SIMD_WORD)
- {
- if (vect_print_dump_info (REPORT_DETAILS, UNKNOWN_LOC))
- fprintf (vect_dump, "vectorizer: target vector size is not defined.");
- return;
- }
-
#ifdef ENABLE_CHECKING
verify_loop_closed_ssa ();
#endif
Index: config/alpha/alpha.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/alpha/alpha.h,v
retrieving revision 1.239
diff -p -u -u -r1.239 alpha.h
--- config/alpha/alpha.h 17 Mar 2005 10:43:19 -0000 1.239
+++ config/alpha/alpha.h 6 Apr 2005 11:55:22 -0000
@@ -394,9 +394,6 @@ extern int alpha_tls_size;
#define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) 1
-/* Our SIMD is all done on single integer registers. */
-#define UNITS_PER_SIMD_WORD UNITS_PER_WORD
-
/* Standard register usage. */
/* Number of actual hardware registers.
Index: config/bfin/bfin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/bfin/bfin.h,v
retrieving revision 1.1
diff -p -u -u -r1.1 bfin.h
--- config/bfin/bfin.h 5 Apr 2005 11:26:48 -0000 1.1
+++ config/bfin/bfin.h 6 Apr 2005 11:55:22 -0000
@@ -787,9 +787,6 @@ do {
/* Width of a word, in units (bytes). */
#define UNITS_PER_WORD 4
-/* Size of a vector for autovectorization. */
-#define UNITS_PER_SIMD_WORD 4
-
/* Width in bits of a pointer.
See also the macro `Pmode1' defined below. */
#define POINTER_SIZE 32
Index: config/i386/i386.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.h,v
retrieving revision 1.426
diff -p -u -u -r1.426 i386.h
--- config/i386/i386.h 5 Apr 2005 22:52:57 -0000 1.426
+++ config/i386/i386.h 6 Apr 2005 08:30:30 -0000
@@ -1089,7 +1089,7 @@ do { \
/* ??? No autovectorization into MMX or 3DNOW until we can reliably
place emms and femms instructions. */
-#define UNITS_PER_SIMD_WORD (TARGET_SSE ? 16 : 0)
+#define UNITS_PER_SIMD_WORD (TARGET_SSE ? 16 : UNITS_PER_WORD)
#define VALID_FP_MODE_P(MODE) \
((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode \
Index: config/ia64/ia64.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/ia64/ia64.h,v
retrieving revision 1.194
diff -p -u -u -r1.194 ia64.h
--- config/ia64/ia64.h 17 Mar 2005 17:35:16 -0000 1.194
+++ config/ia64/ia64.h 6 Apr 2005 11:55:23 -0000
@@ -168,8 +168,6 @@ extern enum processor_type ia64_tune;
#define UNITS_PER_WORD 8
-#define UNITS_PER_SIMD_WORD UNITS_PER_WORD
-
#define POINTER_SIZE (TARGET_ILP32 ? 32 : 64)
/* A C expression whose value is zero if pointers that need to be extended
Index: config/mips/mips.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.h,v
retrieving revision 1.387
diff -p -u -u -r1.387 mips.h
--- config/mips/mips.h 15 Mar 2005 23:02:33 -0000 1.387
+++ config/mips/mips.h 6 Apr 2005 08:30:31 -0000
@@ -966,7 +966,7 @@ extern const struct mips_cpu_info *mips_
/* The number of bytes in a double. */
#define UNITS_PER_DOUBLE (TYPE_PRECISION (double_type_node) / BITS_PER_UNIT)
-#define UNITS_PER_SIMD_WORD (TARGET_PAIRED_SINGLE_FLOAT ? 8 : 0)
+#define UNITS_PER_SIMD_WORD (TARGET_PAIRED_SINGLE_FLOAT ? 8 : UNITS_PER_WORD)
/* Set the sizes of the core types. */
#define SHORT_TYPE_SIZE 16
Index: config/rs6000/rs6000.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.358
diff -p -u -u -r1.358 rs6000.h
--- config/rs6000/rs6000.h 25 Mar 2005 19:50:43 -0000 1.358
+++ config/rs6000/rs6000.h 6 Apr 2005 08:30:32 -0000
@@ -1044,7 +1044,7 @@ extern const char *rs6000_warn_altivec_l
|| (MODE) == V2SImode)
#define UNITS_PER_SIMD_WORD \
- (TARGET_ALTIVEC ? 16 : (TARGET_SPE ? 8 : 0) )
+ (TARGET_ALTIVEC ? 16 : (TARGET_SPE ? 8 : UNITS_PER_WORD) )
/* Value is TRUE if hard register REGNO can hold a value of
machine-mode MODE. */
Index: config/sparc/sparc.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc.h,v
retrieving revision 1.274
diff -p -u -u -r1.274 sparc.h
--- config/sparc/sparc.h 4 Apr 2005 15:29:10 -0000 1.274
+++ config/sparc/sparc.h 6 Apr 2005 08:30:33 -0000
@@ -778,7 +778,7 @@ extern struct sparc_cpu_select sparc_sel
#define MIN_UNITS_PER_WORD 4
#endif
-#define UNITS_PER_SIMD_WORD (TARGET_VIS ? 8 : 0)
+#define UNITS_PER_SIMD_WORD (TARGET_VIS ? 8 : UNITS_PER_WORD)
/* Now define the sizes of the C data types. */