aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@libertysurf.fr>2003-03-09 16:40:00 +0100
committerEric Botcazou <ebotcazou@gcc.gnu.org>2003-03-09 15:40:00 +0000
commit9edf6a4c0f6a3f5c61c9b3f39571059ae3268548 (patch)
treeac83f195034b06baa114c95761f98ce114b0fffe /gcc
parentf937d5e67e709e77a37d0f156945e50bf3946d59 (diff)
downloadgcc-9edf6a4c0f6a3f5c61c9b3f39571059ae3268548.zip
gcc-9edf6a4c0f6a3f5c61c9b3f39571059ae3268548.tar.gz
gcc-9edf6a4c0f6a3f5c61c9b3f39571059ae3268548.tar.bz2
* gcc.dg/i386-loop-1.c: New test.
From-SVN: r64031
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/i386-loop-1.c105
2 files changed, 109 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 15d6935..4c26c48 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2003-03-09 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ * gcc.dg/i386-loop-1.c: New test.
+
2003-03-09 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/9970
diff --git a/gcc/testsuite/gcc.dg/i386-loop-1.c b/gcc/testsuite/gcc.dg/i386-loop-1.c
new file mode 100644
index 0000000..635f012
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/i386-loop-1.c
@@ -0,0 +1,105 @@
+/* PR optimization/9888 */
+/* { dg-do run { target i?86-*-* } } */
+/* { dg-options "-mtune=k6 -O3" } */
+
+/* Verify that GCC doesn't emit out of range 'loop' instructions. */
+
+extern void abort (void);
+extern void exit (int);
+
+
+f1 (a)
+ long a;
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (--a == -1)
+ return i;
+ }
+ return -1;
+}
+
+f2 (a)
+ long a;
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (--a != -1)
+ return i;
+ }
+ return -1;
+}
+
+f3 (a)
+ long a;
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (--a == 0)
+ return i;
+ }
+ return -1;
+}
+
+f4 (a)
+ long a;
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (--a != 0)
+ return i;
+ }
+ return -1;
+}
+
+f5 (a)
+ long a;
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (++a == 0)
+ return i;
+ }
+ return -1;
+}
+
+f6 (a)
+ long a;
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (++a != 0)
+ return i;
+ }
+ return -1;
+}
+
+
+int main()
+{
+ if (f1 (5L) != 5)
+ abort ();
+ if (f2 (1L) != 0)
+ abort ();
+ if (f2 (0L) != 1)
+ abort ();
+ if (f3 (5L) != 4)
+ abort ();
+ if (f4 (1L) != 1)
+ abort ();
+ if (f4 (0L) != 0)
+ abort ();
+ if (f5 (-5L) != 4)
+ abort ();
+ if (f6 (-1L) != 1)
+ abort ();
+ if (f6 (0L) != 0)
+ abort ();
+ exit (0);
+}