From patchwork Sun Oct 16 06:01:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 77692 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp946323qge; Sat, 15 Oct 2016 23:01:33 -0700 (PDT) X-Received: by 10.66.222.230 with SMTP id qp6mr24578659pac.62.1476597693809; Sat, 15 Oct 2016 23:01:33 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id c66si21869568pga.265.2016.10.15.23.01.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Oct 2016 23:01:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-438722-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-438722-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-438722-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=kQZk5UR15qbEFnm1mdXEgRIHA32xQo1a3c6F7SHFNmelNc PmyWkkwvvqAIdaHtbjgBbI7hMEqo0DG4UhOR/6Wi3PAXdA2+O5T2M+GjwPsXmZFz 3OROtzs5CirZwLbBq4mIx13cZa5A7UTn17MkcFKG6p1zY3xMRfJeTEW4g/ffc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=8a9iOXJTj2PtQoMxeasR4fLh2iI=; b=oFTuiOkCJ2XhenP29tJ4 wpmxHeleNVLg91ykxVcZ2uG1e5yu09Y6SZnQJnKI9957Z3H0SrSH9PY/remQhE5A RcJwRNAvuNF+JMr0bNVKA1CrXgH9HiCAsT1nvl9+PSxAh3+ULLLdDLNf1NXisQwf SqdACoIyRNl7bWhsWY6yryA= Received: (qmail 16733 invoked by alias); 16 Oct 2016 06:01:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 16696 invoked by uid 89); 16 Oct 2016 06:01:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=1, 32, dominate X-HELO: mail-io0-f181.google.com Received: from mail-io0-f181.google.com (HELO mail-io0-f181.google.com) (209.85.223.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 16 Oct 2016 06:01:06 +0000 Received: by mail-io0-f181.google.com with SMTP id j37so159639828ioo.3 for ; Sat, 15 Oct 2016 23:01:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=4d9eLZQQpkWXP20wZzzwBte+A1eqL3Q5xfgnZ+hnAv0=; b=Hcwu95yEcolzhrS7iIPNjqQukRNmdxnqu4Hl1XmmYcTmk0ttOCE8hR0Ol3AnUzc+BV GKCjK6dV1tKwNV+9H9OD7nUlArWrNDIpG9QQ3kuUbEP9LNBjmGZU/yM0qXZKe6RnsaYU 7DGQt1XoahBdPFSd6yIkwYKri8PwWmdwwMgj1CXUOWY1Y/Z/pveHVQabft0fmaW4ADhW 72N04vwMKDukMkNKFNPd389FYlKJtG5DtWvdQbr4X2PW1Wn0bCzMnPpbDyF0I+TrFr2b 93FYh4KjJxTJu84ZKzwxGmcK5m3Z09/085y3+kIlNg7S3PIgAPvmoEKkeLdCbCEKEZC+ QkRA== X-Gm-Message-State: AA6/9Rk6sxgq9TRNYMwJK8TGIMRAKhxosZ5lSIF4ZfkPsI5s1G29MCa2uhVG6YX7V+7Kfv7ESkFCooKJsJHxW+Wn X-Received: by 10.107.20.85 with SMTP id 82mr18192607iou.187.1476597663733; Sat, 15 Oct 2016 23:01:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.112.78 with HTTP; Sat, 15 Oct 2016 23:01:03 -0700 (PDT) From: Prathamesh Kulkarni Date: Sun, 16 Oct 2016 11:31:03 +0530 Message-ID: Subject: RFC [3/3] divmod transform v2 - add test cases To: gcc Patches , Richard Biener , Kugan , Jim Wilson X-IsSubscribed: yes Hi, This patch adds test-cases for divmod transform. OK to commit ? Thanks, Prathamesh 2016-10-15 Prathamesh Kulkarni Kugan Vivekanandarajah Jim Wilson testsuite/ * gcc.dg/divmod-1-simode.c: New test. * gcc.dg/divmod-1.c: Likewise. * gcc.dg/divmod-2-simode.c: Likewise. * gcc.dg/divmod-2.c: Likewise. * gcc.dg/divmod-3-simode.c: Likewise. * gcc.dg/divmod-3.c: Likewise. * gcc.dg/divmod-4-simode.c: Likewise. * gcc.dg/divmod-4.c: Likewise. * gcc.dg/divmod-5.c: Likewise. * gcc.dg/divmod-6-simode.c: Likewise. * gcc.dg/divmod-6.c: Likewise. * gcc.dg/divmod-7.c: Likewise. diff --git a/gcc/testsuite/gcc.dg/divmod-1-simode.c b/gcc/testsuite/gcc.dg/divmod-1-simode.c new file mode 100644 index 0000000..9e47799 --- /dev/null +++ b/gcc/testsuite/gcc.dg/divmod-1-simode.c @@ -0,0 +1,25 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* div dominates mod. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype q = x / y; \ + if (cond) \ + foo (); \ + bigtype r = x % y; \ + return q + r; \ +} + +FOO(SImode, SImode, 1) +FOO(SImode, USImode, 2) +FOO(USImode, USImode, 3) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 3 "widening_mul" } } */ diff --git a/gcc/testsuite/gcc.dg/divmod-1.c b/gcc/testsuite/gcc.dg/divmod-1.c new file mode 100644 index 0000000..edcc2a1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/divmod-1.c @@ -0,0 +1,32 @@ +/* { dg-require-effective-target divmod } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* div dominates mod. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +typedef int DImode __attribute__((mode(DI))); +typedef unsigned UDImode __attribute__((mode(DI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype q = x / y; \ + if (cond) \ + foo (); \ + bigtype r = x % y; \ + return q + r; \ +} + +FOO(SImode, DImode, 1) +FOO(SImode, UDImode, 2) +FOO(USImode, DImode, 3) +FOO(USImode, UDImode, 4) +FOO(DImode, DImode, 5) +FOO(DImode, UDImode, 6) +FOO(UDImode, UDImode, 7) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 7 "widening_mul" } } */ diff --git a/gcc/testsuite/gcc.dg/divmod-2-simode.c b/gcc/testsuite/gcc.dg/divmod-2-simode.c new file mode 100644 index 0000000..fa28beb --- /dev/null +++ b/gcc/testsuite/gcc.dg/divmod-2-simode.c @@ -0,0 +1,25 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* mod dominates div. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype r = x % y; \ + if (cond) \ + foo (); \ + bigtype q = x / y; \ + return q + r; \ +} + +FOO(SImode, SImode, 1) +FOO(SImode, USImode, 2) +FOO(USImode, USImode, 3) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 3 "widening_mul" } } */ diff --git a/gcc/testsuite/gcc.dg/divmod-2.c b/gcc/testsuite/gcc.dg/divmod-2.c new file mode 100644 index 0000000..ded732e --- /dev/null +++ b/gcc/testsuite/gcc.dg/divmod-2.c @@ -0,0 +1,32 @@ +/* { dg-require-effective-target divmod } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* mod dominates div. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +typedef int DImode __attribute__((mode(DI))); +typedef unsigned UDImode __attribute__((mode(DI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype r = x % y; \ + if (cond) \ + foo (); \ + bigtype q = x / y; \ + return q + r; \ +} + +FOO(SImode, DImode, 1) +FOO(SImode, UDImode, 2) +FOO(USImode, DImode, 3) +FOO(USImode, UDImode, 4) +FOO(DImode, DImode, 5) +FOO(DImode, UDImode, 6) +FOO(UDImode, UDImode, 7) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 7 "widening_mul" } } */ diff --git a/gcc/testsuite/gcc.dg/divmod-3-simode.c b/gcc/testsuite/gcc.dg/divmod-3-simode.c new file mode 100644 index 0000000..9dee5bf --- /dev/null +++ b/gcc/testsuite/gcc.dg/divmod-3-simode.c @@ -0,0 +1,23 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* div comes before mod in same bb. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype q = x / y; \ + bigtype r = x % y; \ + return q + r; \ +} + +FOO(SImode, SImode, 1) +FOO(SImode, USImode, 2) +FOO(USImode, USImode, 3) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 3 "widening_mul" } } */ diff --git a/gcc/testsuite/gcc.dg/divmod-3.c b/gcc/testsuite/gcc.dg/divmod-3.c new file mode 100644 index 0000000..02aa367 --- /dev/null +++ b/gcc/testsuite/gcc.dg/divmod-3.c @@ -0,0 +1,30 @@ +/* { dg-require-effective-target divmod } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* div comes before mod in same bb. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +typedef int DImode __attribute__((mode(DI))); +typedef unsigned UDImode __attribute__((mode(DI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype q = x / y; \ + bigtype r = x % y; \ + return q + r; \ +} + +FOO(SImode, DImode, 1) +FOO(SImode, UDImode, 2) +FOO(USImode, DImode, 3) +FOO(USImode, UDImode, 4) +FOO(DImode, DImode, 5) +FOO(DImode, UDImode, 6) +FOO(UDImode, UDImode, 7) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 7 "widening_mul" } } */ diff --git a/gcc/testsuite/gcc.dg/divmod-4-simode.c b/gcc/testsuite/gcc.dg/divmod-4-simode.c new file mode 100644 index 0000000..dbe29cb --- /dev/null +++ b/gcc/testsuite/gcc.dg/divmod-4-simode.c @@ -0,0 +1,23 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* mod comes before div in same bb. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype r = x % y; \ + bigtype q = x / y; \ + return q + r; \ +} + +FOO(SImode, SImode, 1) +FOO(SImode, USImode, 2) +FOO(USImode, USImode, 3) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 3 "widening_mul" } } */ diff --git a/gcc/testsuite/gcc.dg/divmod-4.c b/gcc/testsuite/gcc.dg/divmod-4.c new file mode 100644 index 0000000..861ecbd --- /dev/null +++ b/gcc/testsuite/gcc.dg/divmod-4.c @@ -0,0 +1,30 @@ +/* { dg-require-effective-target divmod } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* mod comes before div in same bb. */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +typedef int DImode __attribute__((mode(DI))); +typedef unsigned UDImode __attribute__((mode(DI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype r = x % y; \ + bigtype q = x / y; \ + return q + r; \ +} + +FOO(SImode, DImode, 3) +FOO(SImode, UDImode, 4) +FOO(USImode, DImode, 6) +FOO(USImode, UDImode, 7) +FOO(DImode, DImode, 8) +FOO(DImode, UDImode, 9) +FOO(UDImode, UDImode, 10) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 7 "widening_mul" } } */ diff --git a/gcc/testsuite/gcc.dg/divmod-5.c b/gcc/testsuite/gcc.dg/divmod-5.c new file mode 100644 index 0000000..8a8cee5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/divmod-5.c @@ -0,0 +1,19 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ +/* div and mod are not in same bb and + bb's containing div and mod don't dominate each other. */ + +int f(int x, int y) +{ + int q = 0; + int r = 0; + extern int cond; + + if (cond) + q = x / y; + + r = x % y; + return q + r; +} + +/* { dg-final { scan-tree-dump-times "DIVMOD" 0 "widening_mul" } } */ diff --git a/gcc/testsuite/gcc.dg/divmod-6-simode.c b/gcc/testsuite/gcc.dg/divmod-6-simode.c new file mode 100644 index 0000000..1107f76 --- /dev/null +++ b/gcc/testsuite/gcc.dg/divmod-6-simode.c @@ -0,0 +1,26 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype q = x / y; \ + bigtype r1 = 0, r2 = 0; \ + if (cond) \ + r1 = x % y; \ + else \ + r2 = x % y; \ + return q + r1 + r2; \ +} + +FOO(SImode, SImode, 1) +FOO(SImode, USImode, 2) +FOO(USImode, USImode, 3) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 3 "widening_mul" } } */ diff --git a/gcc/testsuite/gcc.dg/divmod-6.c b/gcc/testsuite/gcc.dg/divmod-6.c new file mode 100644 index 0000000..495ebaf --- /dev/null +++ b/gcc/testsuite/gcc.dg/divmod-6.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target divmod } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ + +typedef int SImode __attribute__((mode(SI))); +typedef unsigned USImode __attribute__((mode(SI))); + +typedef int DImode __attribute__((mode(DI))); +typedef unsigned UDImode __attribute__((mode(DI))); + +extern int cond; +void foo(void); + +#define FOO(smalltype, bigtype, no) \ +bigtype f_##no(smalltype x, bigtype y) \ +{ \ + bigtype q = x / y; \ + bigtype r1 = 0, r2 = 0; \ + if (cond) \ + r1 = x % y; \ + else \ + r2 = x % y; \ + return q + r1 + r2; \ +} + +FOO(SImode, DImode, 3) +FOO(SImode, UDImode, 4) +FOO(USImode, DImode, 6) +FOO(USImode, UDImode, 7) +FOO(DImode, DImode, 8) +FOO(DImode, UDImode, 9) +FOO(UDImode, UDImode, 10) + +/* { dg-final { scan-tree-dump-times "DIVMOD" 7 "widening_mul" } } */ diff --git a/gcc/testsuite/gcc.dg/divmod-7.c b/gcc/testsuite/gcc.dg/divmod-7.c new file mode 100644 index 0000000..faa90b3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/divmod-7.c @@ -0,0 +1,21 @@ +/* { dg-require-effective-target divmod_simode } */ +/* { dg-options "-O2 -fdump-tree-widening_mul-details" } */ + +int f(int x, int y) +{ + int q = 0, r1 = 0, r2 = 0; + extern int cond; + + if (cond) + q = x / y; + else + { + r1 = x % y; + return q + r1; + } + + r2 = x % y; + return q + r2; +} + +/* { dg-final { scan-tree-dump-times "DIVMOD" 1 "widening_mul" } } */