public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/loop-unswitching-switch-v3)] Update tests.
@ 2021-09-13 15:30 Martin Liska
0 siblings, 0 replies; 4+ messages in thread
From: Martin Liska @ 2021-09-13 15:30 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:5875de6f0c4d44291e37695ae5e18602af93daa5
commit 5875de6f0c4d44291e37695ae5e18602af93daa5
Author: Martin Liska <mliska@suse.cz>
Date: Mon Sep 13 14:58:41 2021 +0200
Update tests.
Diff:
---
gcc/testsuite/gcc.dg/loop-unswitch-7.c | 11 -----------
gcc/testsuite/gcc.dg/loop-unswitch-8.c | 28 ++++++++++++++++++++++++++++
gcc/testsuite/gcc.dg/loop-unswitch-9.c | 29 +++++++++++++++++++++++++++++
3 files changed, 57 insertions(+), 11 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/loop-unswitch-7.c b/gcc/testsuite/gcc.dg/loop-unswitch-7.c
index 03904f12e79..00f2fcff64b 100644
--- a/gcc/testsuite/gcc.dg/loop-unswitch-7.c
+++ b/gcc/testsuite/gcc.dg/loop-unswitch-7.c
@@ -2,7 +2,6 @@
/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details --param=max-unswitch-insns=1000 --param=max-unswitch-level=10" } */
int
-__attribute__((noipa))
foo(double *a, double *b, double *c, double *d, double *r, int size, int order)
{
for (int i = 0; i < size; i++)
@@ -40,16 +39,6 @@ foo(double *a, double *b, double *c, double *d, double *r, int size, int order)
return 0;
}
-#define N 16 * 1024
-double aa[N], bb[N], cc[N], dd[N], rr[N];
-
-int main()
-{
- for (int i = 0; i < 100 * 1000; i++)
- foo (aa, bb, cc, dd, rr, N, i % 100);
-}
-
-/* Test that we actually unswitched something. */
/* { dg-final { scan-tree-dump ";; Unswitching loop with condition: order_.* >= 5 & order_.* <= 6 | order_.* == 9" "unswitch" } } */
/* { dg-final { scan-tree-dump ";; Unswitching loop with condition: order.* == 1" "unswitch" } } */
/* { dg-final { scan-tree-dump ";; Unswitching loop with condition: order.* == 2" "unswitch" } } */
diff --git a/gcc/testsuite/gcc.dg/loop-unswitch-8.c b/gcc/testsuite/gcc.dg/loop-unswitch-8.c
new file mode 100644
index 00000000000..4cec1f53bcc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/loop-unswitch-8.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details" } */
+
+int
+foo(double *a, double *b, double *c, double *d, double *r, int size, int order)
+{
+ for (int i = 0; i < size; i++)
+ {
+ double tmp;
+
+ if (order == 1)
+ tmp = -8 * a[i];
+ else
+ tmp = -4 * b[i];
+
+ double x = 3 * tmp + d[i] + tmp;
+
+ if (order == 1)
+ x += 2;
+
+ double y = 3.4f * tmp + d[i];
+ r[i] = x + y;
+ }
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times ";; Unswitching loop with condition: order.* == 1" 1 "unswitch" } } */
diff --git a/gcc/testsuite/gcc.dg/loop-unswitch-9.c b/gcc/testsuite/gcc.dg/loop-unswitch-9.c
new file mode 100644
index 00000000000..28b6e9669d5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/loop-unswitch-9.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details" } */
+
+int
+foo(double *a, double *b, double *c, double *d, double *r, int size, int order)
+{
+ for (int i = 0; i < size; i++)
+ {
+ double tmp;
+
+ if (order < 5)
+ tmp = -8 * a[i];
+ else
+ tmp = -4 * b[i];
+
+ double x = 3 * tmp + d[i] + tmp;
+
+ /* This should not be unswitched as it's mutually excluded with order < 5. */
+ if (order >= 5)
+ x += 2;
+
+ double y = 3.4f * tmp + d[i];
+ r[i] = x + y;
+ }
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times ";; Unswitching loop with condition: order.* == 1" 1 "unswitch" } } */
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gcc(refs/users/marxin/heads/loop-unswitching-switch-v3)] Update tests.
@ 2021-09-13 15:31 Martin Liska
0 siblings, 0 replies; 4+ messages in thread
From: Martin Liska @ 2021-09-13 15:31 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:582dd1d5e42348b71924ecc5446934df23f98b07
commit 582dd1d5e42348b71924ecc5446934df23f98b07
Author: Martin Liska <mliska@suse.cz>
Date: Mon Sep 13 15:04:32 2021 +0200
Update tests.
Diff:
---
gcc/testsuite/gcc.dg/loop-unswitch-9.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/loop-unswitch-9.c b/gcc/testsuite/gcc.dg/loop-unswitch-9.c
index 28b6e9669d5..3058d4a5b38 100644
--- a/gcc/testsuite/gcc.dg/loop-unswitch-9.c
+++ b/gcc/testsuite/gcc.dg/loop-unswitch-9.c
@@ -2,20 +2,25 @@
/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details" } */
int
-foo(double *a, double *b, double *c, double *d, double *r, int size, int order)
+foo(double *a, double *b, double *c, double *d, double *r, int size, unsigned order)
{
for (int i = 0; i < size; i++)
{
double tmp;
- if (order < 5)
- tmp = -8 * a[i];
- else
- tmp = -4 * b[i];
+ switch (order)
+ {
+ case 0 ... 4:
+ tmp = -8 * a[i];
+ break;
+ default:
+ tmp = -4 * b[i];
+ break;
+ }
double x = 3 * tmp + d[i] + tmp;
- /* This should not be unswitched as it's mutually excluded with order < 5. */
+ /* This should not be unswitched as it's mutually excluded with case 0 ... 4. */
if (order >= 5)
x += 2;
@@ -26,4 +31,4 @@ foo(double *a, double *b, double *c, double *d, double *r, int size, int order)
return 0;
}
-/* { dg-final { scan-tree-dump-times ";; Unswitching loop with condition: order.* == 1" 1 "unswitch" } } */
+/* { dg-final { scan-tree-dump-times ";; Unswitching loop with condition: order.* <= 4" 1 "unswitch" } } */
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gcc(refs/users/marxin/heads/loop-unswitching-switch-v3)] Update tests.
@ 2021-09-13 13:27 Martin Liska
0 siblings, 0 replies; 4+ messages in thread
From: Martin Liska @ 2021-09-13 13:27 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a340739c27c12ca41e30f7f4c9d346346f4a1e14
commit a340739c27c12ca41e30f7f4c9d346346f4a1e14
Author: Martin Liska <mliska@suse.cz>
Date: Mon Sep 13 15:04:32 2021 +0200
Update tests.
Diff:
---
gcc/testsuite/gcc.dg/loop-unswitch-9.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/loop-unswitch-9.c b/gcc/testsuite/gcc.dg/loop-unswitch-9.c
index 28b6e9669d5..3058d4a5b38 100644
--- a/gcc/testsuite/gcc.dg/loop-unswitch-9.c
+++ b/gcc/testsuite/gcc.dg/loop-unswitch-9.c
@@ -2,20 +2,25 @@
/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details" } */
int
-foo(double *a, double *b, double *c, double *d, double *r, int size, int order)
+foo(double *a, double *b, double *c, double *d, double *r, int size, unsigned order)
{
for (int i = 0; i < size; i++)
{
double tmp;
- if (order < 5)
- tmp = -8 * a[i];
- else
- tmp = -4 * b[i];
+ switch (order)
+ {
+ case 0 ... 4:
+ tmp = -8 * a[i];
+ break;
+ default:
+ tmp = -4 * b[i];
+ break;
+ }
double x = 3 * tmp + d[i] + tmp;
- /* This should not be unswitched as it's mutually excluded with order < 5. */
+ /* This should not be unswitched as it's mutually excluded with case 0 ... 4. */
if (order >= 5)
x += 2;
@@ -26,4 +31,4 @@ foo(double *a, double *b, double *c, double *d, double *r, int size, int order)
return 0;
}
-/* { dg-final { scan-tree-dump-times ";; Unswitching loop with condition: order.* == 1" 1 "unswitch" } } */
+/* { dg-final { scan-tree-dump-times ";; Unswitching loop with condition: order.* <= 4" 1 "unswitch" } } */
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gcc(refs/users/marxin/heads/loop-unswitching-switch-v3)] Update tests.
@ 2021-09-13 13:27 Martin Liska
0 siblings, 0 replies; 4+ messages in thread
From: Martin Liska @ 2021-09-13 13:27 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e4c0efae10083d5002303e95bfa818c39ebe3bc4
commit e4c0efae10083d5002303e95bfa818c39ebe3bc4
Author: Martin Liska <mliska@suse.cz>
Date: Mon Sep 13 14:58:41 2021 +0200
Update tests.
Diff:
---
gcc/testsuite/gcc.dg/loop-unswitch-7.c | 11 -----------
gcc/testsuite/gcc.dg/loop-unswitch-8.c | 28 ++++++++++++++++++++++++++++
gcc/testsuite/gcc.dg/loop-unswitch-9.c | 29 +++++++++++++++++++++++++++++
3 files changed, 57 insertions(+), 11 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/loop-unswitch-7.c b/gcc/testsuite/gcc.dg/loop-unswitch-7.c
index 03904f12e79..00f2fcff64b 100644
--- a/gcc/testsuite/gcc.dg/loop-unswitch-7.c
+++ b/gcc/testsuite/gcc.dg/loop-unswitch-7.c
@@ -2,7 +2,6 @@
/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details --param=max-unswitch-insns=1000 --param=max-unswitch-level=10" } */
int
-__attribute__((noipa))
foo(double *a, double *b, double *c, double *d, double *r, int size, int order)
{
for (int i = 0; i < size; i++)
@@ -40,16 +39,6 @@ foo(double *a, double *b, double *c, double *d, double *r, int size, int order)
return 0;
}
-#define N 16 * 1024
-double aa[N], bb[N], cc[N], dd[N], rr[N];
-
-int main()
-{
- for (int i = 0; i < 100 * 1000; i++)
- foo (aa, bb, cc, dd, rr, N, i % 100);
-}
-
-/* Test that we actually unswitched something. */
/* { dg-final { scan-tree-dump ";; Unswitching loop with condition: order_.* >= 5 & order_.* <= 6 | order_.* == 9" "unswitch" } } */
/* { dg-final { scan-tree-dump ";; Unswitching loop with condition: order.* == 1" "unswitch" } } */
/* { dg-final { scan-tree-dump ";; Unswitching loop with condition: order.* == 2" "unswitch" } } */
diff --git a/gcc/testsuite/gcc.dg/loop-unswitch-8.c b/gcc/testsuite/gcc.dg/loop-unswitch-8.c
new file mode 100644
index 00000000000..4cec1f53bcc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/loop-unswitch-8.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details" } */
+
+int
+foo(double *a, double *b, double *c, double *d, double *r, int size, int order)
+{
+ for (int i = 0; i < size; i++)
+ {
+ double tmp;
+
+ if (order == 1)
+ tmp = -8 * a[i];
+ else
+ tmp = -4 * b[i];
+
+ double x = 3 * tmp + d[i] + tmp;
+
+ if (order == 1)
+ x += 2;
+
+ double y = 3.4f * tmp + d[i];
+ r[i] = x + y;
+ }
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times ";; Unswitching loop with condition: order.* == 1" 1 "unswitch" } } */
diff --git a/gcc/testsuite/gcc.dg/loop-unswitch-9.c b/gcc/testsuite/gcc.dg/loop-unswitch-9.c
new file mode 100644
index 00000000000..28b6e9669d5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/loop-unswitch-9.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details" } */
+
+int
+foo(double *a, double *b, double *c, double *d, double *r, int size, int order)
+{
+ for (int i = 0; i < size; i++)
+ {
+ double tmp;
+
+ if (order < 5)
+ tmp = -8 * a[i];
+ else
+ tmp = -4 * b[i];
+
+ double x = 3 * tmp + d[i] + tmp;
+
+ /* This should not be unswitched as it's mutually excluded with order < 5. */
+ if (order >= 5)
+ x += 2;
+
+ double y = 3.4f * tmp + d[i];
+ r[i] = x + y;
+ }
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times ";; Unswitching loop with condition: order.* == 1" 1 "unswitch" } } */
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-13 15:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 15:30 [gcc(refs/users/marxin/heads/loop-unswitching-switch-v3)] Update tests Martin Liska
-- strict thread matches above, loose matches on Subject: below --
2021-09-13 15:31 Martin Liska
2021-09-13 13:27 Martin Liska
2021-09-13 13:27 Martin Liska
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).