[gcc(refs/users/marxin/heads/loop-unswitching-switch-v3)] Update tests.

Martin Liska marxin@gcc.gnu.org
Mon Sep 13 13:27:08 GMT 2021


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" } } */


More information about the Gcc-cvs mailing list