From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 552F03857431; Mon, 13 Sep 2021 15:30:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 552F03857431 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/loop-unswitching-switch-v3)] Update tests. X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/loop-unswitching-switch-v3 X-Git-Oldrev: 860179d2bcaed07965ce2d2507ebfb8dd384e3e0 X-Git-Newrev: 5875de6f0c4d44291e37695ae5e18602af93daa5 Message-Id: <20210913153057.552F03857431@sourceware.org> Date: Mon, 13 Sep 2021 15:30:57 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Sep 2021 15:30:57 -0000 https://gcc.gnu.org/g:5875de6f0c4d44291e37695ae5e18602af93daa5 commit 5875de6f0c4d44291e37695ae5e18602af93daa5 Author: Martin Liska 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" } } */