[PATCH] new tests for prefetch for i386
Janis Johnson
janis187@us.ibm.com
Mon Jan 7 11:45:00 GMT 2002
This patch adds test cases for i386 support of __builtin_prefetch and
__builtin_ia32_*prefetch*. Tested on i686-pc-linux-gnu.
Honza, would you please verify that these tests are checking for the
correct behavior? See the comments in the .exp file.
I had hoped to find a way to get a FAIL message from scan-assembler to
report the compiler flags, but didn't. There's a message in the .exp
file saying to look in the log file for more information about failures.
Currently, however, they all pass.
Janis
2002-01-07 Janis Johnson <janis187@us.ibm.com>
* gcc.misc-tests/i386-prefetch.exp: New.
* gcc.misc-tests/i386-pf-3dnow-1.c: New test.
* gcc.misc-tests/i386-pf-3dnow-2.c: New test.
* gcc.misc-tests/i386-pf-athlon-1.c: New test.
* gcc.misc-tests/i386-pf-athlon-2.c: New test.
* gcc.misc-tests/i386-pf-ia32-sse-2.c: New test.
* gcc.misc-tests/i386-pf-none-1.c: New test.
* gcc.misc-tests/i386-pf-sse-1.c: New test.
--- /dev/null Tue May 23 09:27:54 2000
+++ gcc.misc-tests/i386-prefetch.exp Mon Jan 7 10:57:43 2002
@@ -0,0 +1,106 @@
+# Copyright (C) 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Test that the correct data prefetch instructions (SSE or 3DNow! variant,
+# or none) are used for various i386 cpu-type and instruction set
+# extension options for __builtin_prefetch and for ia32-specific prefetch
+# builtins.
+
+# Failure reports do not include the compile option that was used; that
+# information can be seen in the compile line in the log file.
+
+# Do not generate prefetch instructions for the following options.
+
+set PREFETCH_NONE [list \
+ { -mcpu=i386 } \
+ { -mcpu=i486 } \
+ { -mcpu=i586 } \
+ { -mcpu=i686 } \
+ { -mcpu=pentium2 } \
+ { -mcpu=k6 } \
+ { -mcpu=k6-2 } \
+ { -mcpu=k6-3 } \
+ { -march=i386 } \
+ { -march=i486 } \
+ { -march=i586 } \
+ { -march=i686 } \
+ { -march=pentium2 } \
+ { -march=k6 } ]
+
+# For options in PREFETCH_SSE, generate SSE prefetch instructions for
+# __builtin_prefetch. This includes -mcpu for targets that treat prefetch
+# instructions as nops.
+
+set PREFETCH_SSE [list \
+ { -mcpu=pentium3 } \
+ { -mcpu=pentium4 } \
+ { -mcpu=athlon } \
+ { -mcpu=athlon-4 } \
+ { -march=pentium3 } \
+ { -march=pentium4 } ]
+
+# Generate prefetch instructions for __builtin_ia32_prefetch for the following.
+
+set PREFETCH_IA32_SSE [list \
+ { -march=pentium3 } \
+ { -march=pentium4 } ]
+
+# Generate 3DNow! prefetch instructions for the following.
+
+set PREFETCH_3DNOW [list \
+ { -march=k6-2 } \
+ { -march=k6-3 } ]
+
+# Athlon supports both 3DNow! and SSE prefetch instructions. For
+# __builtin_prefetch, generate the 3DNow! instruction for write
+# prefetches but SSE prefetch instructions for read prefetches.
+# Support __builtin_ia32_prefetch_3dnow and __builtin_ia32_prefetchw.
+
+set PREFETCH_ATHLON [list \
+ { -march=athlon } \
+ { -march=athlon-4 } ]
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# Initialize harness.
+dg-init
+
+set torture_with_loops $PREFETCH_NONE
+set torture_without_loops $PREFETCH_NONE
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-none-*.c]] ""
+
+set torture_with_loops $PREFETCH_IA32_SSE
+set torture_without_loops $PREFETCH_IA32_SSE
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-ia32-sse-*.c]] ""
+
+set torture_with_loops $PREFETCH_SSE
+set torture_without_loops $PREFETCH_SSE
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-sse-*.c]] ""
+
+set torture_with_loops $PREFETCH_3DNOW
+set torture_without_loops $PREFETCH_3DNOW
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-3dnow-*.c]] ""
+
+set torture_with_loops $PREFETCH_ATHLON
+set torture_without_loops $PREFETCH_ATHLON
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-athlon-*.c]] ""
+
+dg-finish
--- /dev/null Tue May 23 09:27:54 2000
+++ gcc.misc-tests/i386-pf-3dnow-1.c Fri Jan 4 13:55:45 2002
@@ -0,0 +1,29 @@
+/* Test that the correct data prefetch instructions are generated for i386
+ variants that use 3DNow! prefetch instructions. */
+
+/* { dg-do compile { target i?86-*-* } } */
+
+char *msg = "howdy there";
+
+void foo (char *p)
+{
+ __builtin_prefetch (p, 0, 0);
+ __builtin_prefetch (p, 0, 1);
+ __builtin_prefetch (p, 0, 2);
+ __builtin_prefetch (p, 0, 3);
+ __builtin_prefetch (p, 1, 0);
+ __builtin_prefetch (p, 1, 1);
+ __builtin_prefetch (p, 1, 2);
+ __builtin_prefetch (p, 1, 3);
+}
+
+int main ()
+{
+ foo (msg);
+ exit (0);
+}
+
+/* { dg-final { scan-assembler "prefetch" } } */
+/* { dg-final { scan-assembler "prefetchw" } } */
+/* { dg-final { scan-assembler-not "prefetchnta" } } */
+/* { dg-final { scan-assembler-not "prefetcht" } } */
--- /dev/null Tue May 23 09:27:54 2000
+++ gcc.misc-tests/i386-pf-3dnow-2.c Thu Dec 13 18:48:50 2001
@@ -0,0 +1,24 @@
+/* Test that the correct data prefetch instructions are generated for
+ __builtin_ia32_prefetch_3dnow and __builtin_ia32_prefetchw on x86
+ variants that support those functions. */
+
+/* { dg-do compile { target i?86-*-* } } */
+
+char *msg = "howdy there";
+
+void foo (char *p)
+{
+ __builtin_ia32_prefetch_3dnow (p);
+ __builtin_ia32_prefetchw (p);
+}
+
+int main ()
+{
+ foo (msg);
+ exit (0);
+}
+
+/* { dg-final { scan-assembler "prefetch" } } */
+/* { dg-final { scan-assembler "prefetchw" } } */
+/* { dg-final { scan-assembler-not "prefetchnta" } } */
+/* { dg-final { scan-assembler-not "prefetcht" } } */
--- /dev/null Tue May 23 09:27:54 2000
+++ gcc.misc-tests/i386-pf-athlon-1.c Thu Dec 13 18:35:21 2001
@@ -0,0 +1,29 @@
+/* Test that the correct data prefetch instructions are generated for i386
+ variants that use 3DNow! prefetchw or SSE prefetch instructions with
+ locality hints. */
+
+/* { dg-do compile { target i?86-*-* } } */
+
+char *msg = "howdy there";
+
+void foo (char *p)
+{
+ __builtin_prefetch (p, 0, 0);
+ __builtin_prefetch (p, 0, 1);
+ __builtin_prefetch (p, 0, 2);
+ __builtin_prefetch (p, 0, 3);
+ __builtin_prefetch (p, 1, 0);
+ __builtin_prefetch (p, 1, 1);
+ __builtin_prefetch (p, 1, 2);
+ __builtin_prefetch (p, 1, 3);
+}
+
+int main ()
+{
+ foo (msg);
+ exit (0);
+}
+
+/* { dg-final { scan-assembler "prefetchw" } } */
+/* { dg-final { scan-assembler "prefetchnta" } } */
+/* { dg-final { scan-assembler "prefetcht" } } */
--- /dev/null Tue May 23 09:27:54 2000
+++ gcc.misc-tests/i386-pf-athlon-2.c Thu Dec 13 18:49:08 2001
@@ -0,0 +1,24 @@
+/* Test that the correct data prefetch instructions are generated for
+ __builtin_ia32_prefetch_3dnow and __builtin_ia32_prefetchw on x86
+ variants that support those functions. */
+
+/* { dg-do compile { target i?86-*-* } } */
+
+char *msg = "howdy there";
+
+void foo (char *p)
+{
+ __builtin_ia32_prefetch_3dnow (p);
+ __builtin_ia32_prefetchw (p);
+}
+
+int main ()
+{
+ foo (msg);
+ exit (0);
+}
+
+/* { dg-final { scan-assembler "prefetch" } } */
+/* { dg-final { scan-assembler "prefetchw" } } */
+/* { dg-final { scan-assembler-not "prefetchnta" } } */
+/* { dg-final { scan-assembler-not "prefetcht" } } */
--- /dev/null Tue May 23 09:27:54 2000
+++ gcc.misc-tests/i386-pf-ia32-sse-2.c Fri Jan 4 14:12:29 2002
@@ -0,0 +1,26 @@
+/* Test that the correct data prefetch instructions are generated for
+ __buildin_ia32_prefetch on x86 variants that support it. */
+
+/* { dg-do compile { target i?86-*-* } } */
+
+char *msg = "howdy there";
+
+void foo (char *p)
+{
+ __builtin_ia32_prefetch (p, 0);
+ __builtin_ia32_prefetch (p, 1);
+ __builtin_ia32_prefetch (p, 2);
+ __builtin_ia32_prefetch (p, 3);
+}
+
+int main ()
+{
+ foo (msg);
+ exit (0);
+}
+
+/* { dg-final { scan-assembler "prefetchnta" } } */
+/* { dg-final { scan-assembler "prefetcht0" } } */
+/* { dg-final { scan-assembler "prefetcht1" } } */
+/* { dg-final { scan-assembler "prefetcht2" } } */
+/* { dg-final { scan-assembler-not "prefetchw" } } */
--- /dev/null Tue May 23 09:27:54 2000
+++ gcc.misc-tests/i386-pf-none-1.c Thu Dec 13 14:05:03 2001
@@ -0,0 +1,26 @@
+/* Test that data prefetch instructions are not generated for i386 variants
+ that do not support those instructions. */
+
+/* { dg-do compile { target i?86-*-* } } */
+
+char *msg = "howdy there";
+
+void foo (char *p)
+{
+ __builtin_prefetch (p, 0, 0);
+ __builtin_prefetch (p, 0, 1);
+ __builtin_prefetch (p, 0, 2);
+ __builtin_prefetch (p, 0, 3);
+ __builtin_prefetch (p, 1, 0);
+ __builtin_prefetch (p, 1, 1);
+ __builtin_prefetch (p, 1, 2);
+ __builtin_prefetch (p, 1, 3);
+}
+
+int main ()
+{
+ foo (msg);
+ exit (0);
+}
+
+/* { dg-final { scan-assembler-not "fetch" } } */
--- /dev/null Tue May 23 09:27:54 2000
+++ gcc.misc-tests/i386-pf-sse-1.c Thu Dec 13 14:05:03 2001
@@ -0,0 +1,30 @@
+/* Test that the correct data prefetch instructions are generated for i386
+ variants that use SSE prefetch instructions. */
+
+/* { dg-do compile { target i?86-*-* } } */
+
+char *msg = "howdy there";
+
+void foo (char *p)
+{
+ __builtin_prefetch (p, 0, 0);
+ __builtin_prefetch (p, 0, 1);
+ __builtin_prefetch (p, 0, 2);
+ __builtin_prefetch (p, 0, 3);
+ __builtin_prefetch (p, 1, 0);
+ __builtin_prefetch (p, 1, 1);
+ __builtin_prefetch (p, 1, 2);
+ __builtin_prefetch (p, 1, 3);
+}
+
+int main ()
+{
+ foo (msg);
+ exit (0);
+}
+
+/* { dg-final { scan-assembler "prefetchnta" } } */
+/* { dg-final { scan-assembler "prefetcht0" } } */
+/* { dg-final { scan-assembler "prefetcht1" } } */
+/* { dg-final { scan-assembler "prefetcht2" } } */
+/* { dg-final { scan-assembler-not "prefetchw" } } */
More information about the Gcc-patches
mailing list