[PATCH] More restrict testcases
Richard Biener
rguenther@suse.de
Tue Oct 29 14:45:00 GMT 2013
Just figured while "optimizing" Michas ADD_RESTRICT patch ...
(well, make it "work").
Tested on x86_64-unknown-linux-gnu, committed.
Richard.
2013-10-29 Richard Biener <rguenther@suse.de>
* gcc.dg/torture/restrict-2.c: New testcase.
* gcc.dg/torture/restrict-3.c: Likewise.
* gcc.dg/torture/restrict-4.c: Likewise.
* gcc.dg/torture/restrict-5.c: Likewise.
Index: gcc/testsuite/gcc.dg/torture/restrict-2.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/restrict-2.c (revision 0)
+++ gcc/testsuite/gcc.dg/torture/restrict-2.c (working copy)
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+static inline void
+foo (int * p)
+{
+ int * __restrict pr = p;
+ *pr = 1;
+}
+
+int __attribute__((noinline,noclone))
+bar (int *q)
+{
+ int * __restrict qr = q;
+ *qr = 0;
+ foo (qr);
+ return *qr;
+}
+
+int main()
+{
+ int i;
+ if (bar (&i) != 1)
+ abort ();
+ return 0;
+}
Index: gcc/testsuite/gcc.dg/torture/restrict-3.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/restrict-3.c (revision 0)
+++ gcc/testsuite/gcc.dg/torture/restrict-3.c (working copy)
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+static inline void
+foo (int * __restrict pr)
+{
+ *pr = 1;
+}
+
+int __attribute__((noinline,noclone))
+bar (int *q)
+{
+ int * __restrict qr = q;
+ *qr = 0;
+ foo (qr);
+ return *qr;
+}
+
+int main()
+{
+ int i;
+ if (bar (&i) != 1)
+ abort ();
+ return 0;
+}
Index: gcc/testsuite/gcc.dg/torture/restrict-4.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/restrict-4.c (revision 0)
+++ gcc/testsuite/gcc.dg/torture/restrict-4.c (working copy)
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+static inline void
+foo (int * p)
+{
+ int * __restrict pr = p;
+ *pr = 1;
+}
+
+int __attribute__((noinline,noclone))
+bar (int * __restrict qr)
+{
+ *qr = 0;
+ foo (qr);
+ return *qr;
+}
+
+int main()
+{
+ int i;
+ if (bar (&i) != 1)
+ abort ();
+ return 0;
+}
Index: gcc/testsuite/gcc.dg/torture/restrict-5.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/restrict-5.c (revision 0)
+++ gcc/testsuite/gcc.dg/torture/restrict-5.c (working copy)
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+static inline void
+foo (int * __restrict pr)
+{
+ *pr = 1;
+}
+
+int __attribute__((noinline,noclone))
+bar (int * __restrict qr)
+{
+ *qr = 0;
+ foo (qr);
+ return *qr;
+}
+
+int main()
+{
+ int i;
+ if (bar (&i) != 1)
+ abort ();
+ return 0;
+}
More information about the Gcc-patches
mailing list