[PATCH, function-specific, committed] Rev up function specific branch to 137119.
Michael Meissner
michael.meissner@amd.com
Wed Jun 25 22:25:00 GMT 2008
I rev'ed up the function specific branch to sync with trunk revision 137119.
In addition, I applied the following patches:
[gcc]
2008-06-25 Michael Meissner <michael.meissner@amd.com>
* config/i386/i386.c (ix86_valid_option_attribute_inner_p): Use
ASTRDUP instead of naked alloca.
* c-common.c (parse_optimize_options): Use ASTRDUP instead of
naked alloca. Use ggc_alloc to allocate string instead of
using alloca and then ggc_strdup.
[gcc/testsuite]
2008-06-25 Michael Meissner <michael.meissner@amd.com>
* gcc.target/i386/sse-22.c: Specify all target options in one
#pragma instead of separately. Eliminate using
-fno-unit-at-a-time switch.
* gcc.target/i386/opt-2.c: New file.
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c (revision 137119)
+++ gcc/config/i386/i386.c (working copy)
@@ -3385,9 +3390,7 @@ ix86_valid_option_attribute_inner_p (tre
gcc_unreachable ();
/* Handle multiple arguments separated by commas. */
- next_optstr = (char *) alloca (TREE_STRING_LENGTH (args) + 1);
- memcpy (next_optstr, TREE_STRING_POINTER (args), TREE_STRING_LENGTH (args));
- next_optstr[ TREE_STRING_LENGTH (args) ] = '\0';
+ next_optstr = ASTRDUP (TREE_STRING_POINTER (args));
while (next_optstr && *next_optstr != '\0')
{
Index: gcc/c-common.c
===================================================================
--- gcc/c-common.c (revision 137119)
+++ gcc/c-common.c (working copy)
@@ -6651,15 +6654,13 @@ parse_optimize_options (tree args, bool
else if (TREE_CODE (value) == STRING_CST)
{
+ /* Split string into multiple substrings. */
size_t len = TREE_STRING_LENGTH (value);
- char *p = (char *) alloca (len + 1);
+ char *p = ASTRDUP (TREE_STRING_POINTER (value));
char *end = p + len;
char *comma;
char *next_p = p;
- /* Split string into multiple substrings. */
- memcpy (p, TREE_STRING_POINTER (value), len+1);
-
while (next_p != NULL)
{
size_t len2;
@@ -6679,7 +6680,7 @@ parse_optimize_options (tree args, bool
next_p = NULL;
}
- r = q = (char *) alloca (len2 + 3);
+ r = q = (char *) ggc_alloc (len2 + 3);
/* If the user supplied -Oxxx or -fxxx, only allow -Oxxx or -fxxx
options. */
@@ -6710,7 +6711,7 @@ parse_optimize_options (tree args, bool
memcpy (r, p, len2);
r[len2] = '\0';
- VEC_safe_push (const_char_p, gc, optimize_args, ggc_strdup (q));
+ VEC_safe_push (const_char_p, gc, optimize_args, q);
}
}
Index: gcc/testsuite/gcc.target/i386/sse-22.c
===================================================================
--- gcc/testsuite/gcc.target/i386/sse-22.c (revision 137122)
+++ gcc/testsuite/gcc.target/i386/sse-22.c (revision 137123)
@@ -1,6 +1,6 @@
/* Same as sse-14, except converted to use #pragma GCC option. */
/* { dg-do compile } */
-/* { dg-options "-O0 -Werror-implicit-function-declaration -fno-unit-at-a-time" } */
+/* { dg-options "-O0 -Werror-implicit-function-declaration" } */
#include <mm_malloc.h>
@@ -36,19 +36,29 @@
{ return func (A, B, C, D, imm); }
+#ifndef DIFFERENT_PRAGMAS
+#pragma GCC option ("mmx,3dnow,sse,sse2,sse3,ssse3,sse4.1,sse4.2,sse5,aes,pclmul")
+#endif
+
/* Following intrinsics require immediate arguments. They
are defined as macros for non-optimized compilations. */
/* mmintrin.h (MMX). */
+#ifdef DIFFERENT_PRAGMAS
#pragma GCC option ("mmx")
+#endif
#include <mmintrin.h>
/* mm3dnow.h (3DNOW). */
+#ifdef DIFFERENT_PRAGMAS
#pragma GCC option ("3dnow")
+#endif
#include <mm3dnow.h>
/* xmmintrin.h (SSE). */
+#ifdef DIFFERENT_PRAGMAS
#pragma GCC option ("sse")
+#endif
#include <xmmintrin.h>
test_2 (_mm_shuffle_ps, __m128, __m128, __m128, 1)
test_1 (_mm_extract_pi16, int, __m64, 1)
@@ -60,7 +70,9 @@ test_1 (_m_pshufw, __m64, __m64, 1)
test_1 (_mm_prefetch, void, void *, _MM_HINT_NTA)
/* emmintrin.h (SSE2). */
+#ifdef DIFFERENT_PRAGMAS
#pragma GCC option ("sse2")
+#endif
#include <emmintrin.h>
test_2 (_mm_shuffle_pd, __m128d, __m128d, __m128d, 1)
test_1 (_mm_srli_si128, __m128i, __m128i, 1)
@@ -72,17 +84,23 @@ test_1 (_mm_shufflelo_epi16, __m128i, __
test_1 (_mm_shuffle_epi32, __m128i, __m128i, 1)
/* pmmintrin.h (SSE3). */
+#ifdef DIFFERENT_PRAGMAS
#pragma GCC option ("sse3")
+#endif
#include <pmmintrin.h>
/* tmmintrin.h (SSSE3). */
+#ifdef DIFFERENT_PRAGMAS
#pragma GCC option ("ssse3")
+#endif
#include <tmmintrin.h>
test_2 (_mm_alignr_epi8, __m128i, __m128i, __m128i, 1)
test_2 (_mm_alignr_pi8, __m64, __m64, __m64, 1)
/* ammintrin.h (SSE4A). */
+#ifdef DIFFERENT_PRAGMAS
#pragma GCC option ("sse4a")
+#endif
#include <ammintrin.h>
test_1x (_mm_extracti_si64, __m128i, __m128i, 1, 1)
test_2x (_mm_inserti_si64, __m128i, __m128i, __m128i, 1, 1)
@@ -91,7 +109,9 @@ test_2x (_mm_inserti_si64, __m128i, __m1
/* nmmintrin.h (SSE4.2). */
/* Note, nmmintrin.h includes smmintrin.h, and smmintrin.h checks for the
#ifdef. So just set the option to SSE4.2. */
+#ifdef DIFFERENT_PRAGMAS
#pragma GCC option ("sse4.2")
+#endif
#include <nmmintrin.h>
test_2 (_mm_blend_epi16, __m128i, __m128i, __m128i, 1)
test_2 (_mm_blend_ps, __m128, __m128, __m128, 1)
@@ -127,7 +147,9 @@ test_4 (_mm_cmpestrs, int, __m128i, int,
test_4 (_mm_cmpestrz, int, __m128i, int, __m128i, int, 1)
/* bmmintrin.h (SSE5). */
+#ifdef DIFFERENT_PRAGMAS
#pragma GCC option ("sse5")
+#endif
#include <bmmintrin.h>
test_1 (_mm_roti_epi8, __m128i, __m128i, 1)
test_1 (_mm_roti_epi16, __m128i, __m128i, 1)
@@ -135,7 +157,9 @@ test_1 (_mm_roti_epi32, __m128i, __m128i
test_1 (_mm_roti_epi64, __m128i, __m128i, 1)
/* wmmintrin.h (AES/PCLMUL). */
+#ifdef DIFFERENT_PRAGMAS
#pragma GCC option ("aes,pclmul")
+#endif
#include <wmmintrin.h>
test_1 (_mm_aeskeygenassist_si128, __m128i, __m128i, 1)
test_2 (_mm_clmulepi64_si128, __m128i, __m128i, __m128i, 1)
--- gcc/testsuite/gcc.target/i386/opt-2.c.~1~ 2008-06-25 17:35:23.225447000 -0400
+++ gcc/testsuite/gcc.target/i386/opt-2.c 2008-06-21 08:37:26.000000000 -0400
@@ -0,0 +1,38 @@
+/* Test the attribute((optimize)) really works. Do this test by checking
+ whether we vectorize a simple loop. */
+/* { dg-do compile } */
+/* { dg-options "-O1 -msse2 -mfpmath=sse -march=k8" } */
+/* { dg-final { scan-assembler "prefetcht0" } } */
+/* { dg-final { scan-assembler "addps" } } */
+/* { dg-final { scan-assembler "subss" } } */
+
+#define SIZE 10240
+float a[SIZE] __attribute__((__aligned__(32)));
+float b[SIZE] __attribute__((__aligned__(32)));
+float c[SIZE] __attribute__((__aligned__(32)));
+
+/* This should vectorize. */
+#pragma GCC optimize push
+#pragma GCC optimize (3, "unroll-all-loops", "-fprefetch-loop-arrays")
+
+void
+opt3 (void)
+{
+ int i;
+
+ for (i = 0; i < SIZE; i++)
+ a[i] = b[i] + c[i];
+}
+
+#pragma GCC optimize pop
+
+/* This should not vectorize. */
+void
+not_opt3 (void)
+{
+ int i;
+
+ for (i = 0; i < SIZE; i++)
+ a[i] = b[i] - c[i];
+}
+
--
Michael Meissner, AMD
90 Central Street, MS 83-29, Boxborough, MA, 01719, USA
michael.meissner@amd.com
More information about the Gcc-patches
mailing list