Message ID | 20220803191014.2284344-1-sfeifer@redhat.com |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp536047pxt; Wed, 3 Aug 2022 12:11:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vAkmGYjiXljoB7JEdw2crTkEIvUBgIMM+/47DmP3rzaF6bwJBsnUYzSk4/awW0Q840EUMK X-Received: by 2002:a17:907:9809:b0:72f:817:d433 with SMTP id ji9-20020a170907980900b0072f0817d433mr21508838ejc.483.1659553867156; Wed, 03 Aug 2022 12:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659553867; cv=none; d=google.com; s=arc-20160816; b=DOVzETHWbJn95vXY8NMrXbY9sn6Q5wjfKXVWTJRqTVZkuNwlsZwIoVfPPgNTTTBSr4 QFyW+X9H9Fl3YK3RqaQ750cz/CragiUXSVmTnfOd9EZ9mX5fCnYqn60JKl/oNdvSwbHM NWUYwfUEgQsov1T22OsCCKkjzGIw/UZMgYE5meGmN/KGy30DcjgSvPsQMzoriEpJebDz eCiM32zKblbEQms89aGAQyezAH1bY6h5QhpA7cW0DzLUmOh2+BukCBwuHdxvxJPyyWMl MpoB0t5QNelVGNbBSDErkA6gVdV213Kg4JXUwMmJGie4KoIDcI3YelBfBD+pLLnmGzRx OOUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=kQq5Z3iX++7RLmJPWaEvuzXThxYntDYghz8VplyRMtA=; b=Sw1gnqtq9VuZrpp2ZcGKwKqLibAcpGxmuSlRr87HfGUDE7w2+wkq0IlgFo7a8tG7ko geZdwUUIFG3kyI5Czef4wL6Ciy64w6L1Iudic1INE3LktQQfcOkGze3LLJF4UfHZqwei LKHzeZM5N4OEsctpvTeVrCNe3uoyomak62QlNhEm8M5sYb/EcZB85+ft+g5MQPT7/qTb JG+/6DuC2WVdQHQB1tMfAC1lEcf1ek71hnGnUWXa2lke4I6VzaUfxlxc1mMBsQeg+YS6 IaHvuftMDvDvASwnpXurO7jNA5NuPkSvR7NlMbAGW+mu+F7HV/scJHXN/s5juqRuS18f 0Phw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="Hl/2Ipqz"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g22-20020a056402321600b0043cfcf25a48si6118653eda.489.2022.08.03.12.11.06 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Aug 2022 12:11:07 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="Hl/2Ipqz"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 082703857C4A for <ouuuleilei@gmail.com>; Wed, 3 Aug 2022 19:11:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 082703857C4A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659553866; bh=kQq5Z3iX++7RLmJPWaEvuzXThxYntDYghz8VplyRMtA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Hl/2Ipqz+4km84vp/Nr5CjRF0Vv0J6SvKXT0YFCoRJjsUsr0oD2yazUvSPfLy742M GZsW8UIXjYL0CGOw9pTBaS7XF0pOvfOb/X7xXuNa+bMDRk3qvTLKOJ1atSeXYFSNPH DqdfEjAr0nXBy8PmqJS1XsyJe1ZR5at/nwHf+Kco= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 559D83858413 for <gcc-patches@gcc.gnu.org>; Wed, 3 Aug 2022 19:10:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 559D83858413 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-97--fs0gEABP9i4Ramo1FhskQ-1; Wed, 03 Aug 2022 15:10:21 -0400 X-MC-Unique: -fs0gEABP9i4Ramo1FhskQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BB2F585A588 for <gcc-patches@gcc.gnu.org>; Wed, 3 Aug 2022 19:10:20 +0000 (UTC) Received: from sfeifer.remote.csb (unknown [10.22.8.218]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C4231415116 for <gcc-patches@gcc.gnu.org>; Wed, 3 Aug 2022 19:10:20 +0000 (UTC) To: GCC Patches <gcc-patches@gcc.gnu.org> Subject: [PATCH] match.pd: Add bitwise and pattern [PR106243] Date: Wed, 3 Aug 2022 15:10:14 -0400 Message-Id: <20220803191014.2284344-1-sfeifer@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Sam Feifer via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Sam Feifer <sfeifer@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740168355834297484?= X-GMAIL-MSGID: =?utf-8?q?1740168355834297484?= |
Series |
match.pd: Add bitwise and pattern [PR106243]
|
|
Commit Message
Sam Feifer
Aug. 3, 2022, 7:10 p.m. UTC
This patch adds a new optimization to match.pd. The pattern, -x & 1, now gets simplified to x & 1, reducing the number of instructions produced. This patch also adds tests for the optimization rule. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? PR tree-optimization/106243 gcc/ChangeLog: * match.pd (-x & 1): New simplification. gcc/testsuite/ChangeLog: * gcc.dg/pr106243-1.c: New test. * gcc.dg/pr106243.c: New test. --- gcc/match.pd | 5 ++++ gcc/testsuite/gcc.dg/pr106243-1.c | 18 +++++++++++++ gcc/testsuite/gcc.dg/pr106243.c | 43 +++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr106243-1.c create mode 100644 gcc/testsuite/gcc.dg/pr106243.c base-commit: 388fbbd895e72669909173c3003ae65c6483a3c2
Comments
On Thu, 4 Aug 2022 at 00:41, Sam Feifer via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > This patch adds a new optimization to match.pd. The pattern, -x & 1, > now gets simplified to x & 1, reducing the number of instructions > produced. Hi Sam, No comments on patch, but wondering if we can similarly add another pattern to simplify abs(x) & 1 -> x & 1 ? Currently we don't appear to do it on GIMPLE: __attribute__((noipa)) int f1 (int x) { return __builtin_abs (x) & 1; } .optimized dump shows: _1 = ABS_EXPR <x_2(D)>; _3 = _1 & 1; return _3; altho combine simplifies it to x & 1 on RTL, resulting in code-gen: f1: and w0, w0, 1 ret Thanks, Prathamesh > > This patch also adds tests for the optimization rule. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > PR tree-optimization/106243 > > gcc/ChangeLog: > > * match.pd (-x & 1): New simplification. > > gcc/testsuite/ChangeLog: > > * gcc.dg/pr106243-1.c: New test. > * gcc.dg/pr106243.c: New test. > --- > gcc/match.pd | 5 ++++ > gcc/testsuite/gcc.dg/pr106243-1.c | 18 +++++++++++++ > gcc/testsuite/gcc.dg/pr106243.c | 43 +++++++++++++++++++++++++++++++ > 3 files changed, 66 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/pr106243-1.c > create mode 100644 gcc/testsuite/gcc.dg/pr106243.c > > diff --git a/gcc/match.pd b/gcc/match.pd > index 562138a8034..78b32567836 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -8061,3 +8061,8 @@ and, > (if (TYPE_UNSIGNED (TREE_TYPE (@0))) > (bit_and @0 @1) > (cond (le @0 @1) @0 (bit_and @0 @1)))))) > + > +/* -x & 1 -> x & 1. */ > +(simplify > + (bit_and:c (negate @0) integer_onep@1) > + (bit_and @0 @1)) > diff --git a/gcc/testsuite/gcc.dg/pr106243-1.c b/gcc/testsuite/gcc.dg/pr106243-1.c > new file mode 100644 > index 00000000000..b1dbe5cbe44 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr106243-1.c > @@ -0,0 +1,18 @@ > +/* PR tree-optimization/106243 */ > +/* { dg-do run } */ > +/* { dg-options "-O2" } */ > + > +#include "pr106243.c" > + > +int main () { > + > + if (foo(3) != 1 > + || bar(-6) != 0 > + || baz(17) != 1 > + || qux(-128) != 0 > + || foo(127) != 1) { > + __builtin_abort(); > + } > + > + return 0; > +} > diff --git a/gcc/testsuite/gcc.dg/pr106243.c b/gcc/testsuite/gcc.dg/pr106243.c > new file mode 100644 > index 00000000000..ee2706f2bf9 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr106243.c > @@ -0,0 +1,43 @@ > +/* PR tree-optimization/106243 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fdump-tree-optimized" } */ > + > +#define vector __attribute__((vector_size(4*sizeof(int)))) > + > +/* Test from PR. */ > +__attribute__((noipa)) int foo (int x) { > + return -x & 1; > +} > + > +/* Other test from PR. */ > +__attribute__((noipa)) int bar (int x) { > + return (0 - x) & 1; > +} > + > +/* Forward propogation. */ > +__attribute__((noipa)) int baz (int x) { > + x = -x; > + return x & 1; > +} > + > +/* Commutative property. */ > +__attribute__((noipa)) int qux (int x) { > + return 1 & -x; > +} > + > +/* Vector test case. */ > +__attribute__((noipa)) vector int waldo (vector int x) { > + return -x & 1; > +} > + > +/* Should not simplify. */ > +__attribute__((noipa)) int thud (int x) { > + return -x & 2; > +} > + > +/* Should not simplify. */ > +__attribute__((noipa)) int corge (int x) { > + return -x & -1; > +} > + > +/* { dg-final {scan-tree-dump-times "-" 2 "optimized" } } */ > > base-commit: 388fbbd895e72669909173c3003ae65c6483a3c2 > -- > 2.31.1 >
On 8/3/2022 2:44 PM, Prathamesh Kulkarni via Gcc-patches wrote: > On Thu, 4 Aug 2022 at 00:41, Sam Feifer via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: >> This patch adds a new optimization to match.pd. The pattern, -x & 1, >> now gets simplified to x & 1, reducing the number of instructions >> produced. > Hi Sam, > No comments on patch, but wondering if we can similarly add another pattern to > simplify abs(x) & 1 -> x & 1 ? > Currently we don't appear to do it on GIMPLE: > > __attribute__((noipa)) > int f1 (int x) > { > return __builtin_abs (x) & 1; > } > > .optimized dump shows: > _1 = ABS_EXPR <x_2(D)>; > _3 = _1 & 1; > return _3; > > altho combine simplifies it to x & 1 on RTL, resulting in code-gen: > f1: > and w0, w0, 1 > ret Doesn't the abs(x) & mask simplify to x & mask for any mask where the sign bit of x is off -- including cases where mask isn't necessarily a compile-time constant, but we have range data which allows us to know that x's sign bit is off in mask. jeff
On Wed, Aug 3, 2022 at 9:11 PM Sam Feifer via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > This patch adds a new optimization to match.pd. The pattern, -x & 1, > now gets simplified to x & 1, reducing the number of instructions > produced. > > This patch also adds tests for the optimization rule. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > PR tree-optimization/106243 > > gcc/ChangeLog: > > * match.pd (-x & 1): New simplification. > > gcc/testsuite/ChangeLog: > > * gcc.dg/pr106243-1.c: New test. > * gcc.dg/pr106243.c: New test. > --- > gcc/match.pd | 5 ++++ > gcc/testsuite/gcc.dg/pr106243-1.c | 18 +++++++++++++ > gcc/testsuite/gcc.dg/pr106243.c | 43 +++++++++++++++++++++++++++++++ > 3 files changed, 66 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/pr106243-1.c > create mode 100644 gcc/testsuite/gcc.dg/pr106243.c > > diff --git a/gcc/match.pd b/gcc/match.pd > index 562138a8034..78b32567836 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -8061,3 +8061,8 @@ and, > (if (TYPE_UNSIGNED (TREE_TYPE (@0))) > (bit_and @0 @1) > (cond (le @0 @1) @0 (bit_and @0 @1)))))) > + > +/* -x & 1 -> x & 1. */ > +(simplify > + (bit_and:c (negate @0) integer_onep@1) Note the bit_and doesn't need :c because constant operands are always canonicalized second. OK with that change. Thanks, Richard. > + (bit_and @0 @1)) > diff --git a/gcc/testsuite/gcc.dg/pr106243-1.c b/gcc/testsuite/gcc.dg/pr106243-1.c > new file mode 100644 > index 00000000000..b1dbe5cbe44 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr106243-1.c > @@ -0,0 +1,18 @@ > +/* PR tree-optimization/106243 */ > +/* { dg-do run } */ > +/* { dg-options "-O2" } */ > + > +#include "pr106243.c" > + > +int main () { > + > + if (foo(3) != 1 > + || bar(-6) != 0 > + || baz(17) != 1 > + || qux(-128) != 0 > + || foo(127) != 1) { > + __builtin_abort(); > + } > + > + return 0; > +} > diff --git a/gcc/testsuite/gcc.dg/pr106243.c b/gcc/testsuite/gcc.dg/pr106243.c > new file mode 100644 > index 00000000000..ee2706f2bf9 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr106243.c > @@ -0,0 +1,43 @@ > +/* PR tree-optimization/106243 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fdump-tree-optimized" } */ > + > +#define vector __attribute__((vector_size(4*sizeof(int)))) > + > +/* Test from PR. */ > +__attribute__((noipa)) int foo (int x) { > + return -x & 1; > +} > + > +/* Other test from PR. */ > +__attribute__((noipa)) int bar (int x) { > + return (0 - x) & 1; > +} > + > +/* Forward propogation. */ > +__attribute__((noipa)) int baz (int x) { > + x = -x; > + return x & 1; > +} > + > +/* Commutative property. */ > +__attribute__((noipa)) int qux (int x) { > + return 1 & -x; > +} > + > +/* Vector test case. */ > +__attribute__((noipa)) vector int waldo (vector int x) { > + return -x & 1; > +} > + > +/* Should not simplify. */ > +__attribute__((noipa)) int thud (int x) { > + return -x & 2; > +} > + > +/* Should not simplify. */ > +__attribute__((noipa)) int corge (int x) { > + return -x & -1; > +} > + > +/* { dg-final {scan-tree-dump-times "-" 2 "optimized" } } */ > > base-commit: 388fbbd895e72669909173c3003ae65c6483a3c2 > -- > 2.31.1 >
On Thu, Aug 4, 2022 at 12:40 AM Jeff Law via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > > > On 8/3/2022 2:44 PM, Prathamesh Kulkarni via Gcc-patches wrote: > > On Thu, 4 Aug 2022 at 00:41, Sam Feifer via Gcc-patches > > <gcc-patches@gcc.gnu.org> wrote: > >> This patch adds a new optimization to match.pd. The pattern, -x & 1, > >> now gets simplified to x & 1, reducing the number of instructions > >> produced. > > Hi Sam, > > No comments on patch, but wondering if we can similarly add another pattern to > > simplify abs(x) & 1 -> x & 1 ? > > Currently we don't appear to do it on GIMPLE: > > > > __attribute__((noipa)) > > int f1 (int x) > > { > > return __builtin_abs (x) & 1; > > } > > > > .optimized dump shows: > > _1 = ABS_EXPR <x_2(D)>; > > _3 = _1 & 1; > > return _3; > > > > altho combine simplifies it to x & 1 on RTL, resulting in code-gen: > > f1: > > and w0, w0, 1 > > ret > Doesn't the abs(x) & mask simplify to x & mask for any mask where the > sign bit of x is off -- including cases where mask isn't necessarily a > compile-time constant, but we have range data which allows us to know > that x's sign bit is off in mask. You can use tree_expr_nonnegative_p but then that does simplify abs(x) to x already. But sure, handling abs() like negate sounds it should work. Richard, > jeff > > >
Hello, On Wed, 3 Aug 2022, Jeff Law via Gcc-patches wrote: > > .optimized dump shows: > > _1 = ABS_EXPR <x_2(D)>; > > _3 = _1 & 1; > > return _3; > > > > altho combine simplifies it to x & 1 on RTL, resulting in code-gen: > > f1: > > and w0, w0, 1 > > ret > Doesn't the abs(x) & mask simplify to x & mask for any mask where the sign bit > of x is off No. Only the lowest bit remains the same between x and -x, all others might or might not be inverted (first counter example: x=-3, mask=3). Ciao, Michael.
diff --git a/gcc/match.pd b/gcc/match.pd index 562138a8034..78b32567836 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -8061,3 +8061,8 @@ and, (if (TYPE_UNSIGNED (TREE_TYPE (@0))) (bit_and @0 @1) (cond (le @0 @1) @0 (bit_and @0 @1)))))) + +/* -x & 1 -> x & 1. */ +(simplify + (bit_and:c (negate @0) integer_onep@1) + (bit_and @0 @1)) diff --git a/gcc/testsuite/gcc.dg/pr106243-1.c b/gcc/testsuite/gcc.dg/pr106243-1.c new file mode 100644 index 00000000000..b1dbe5cbe44 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr106243-1.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/106243 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "pr106243.c" + +int main () { + + if (foo(3) != 1 + || bar(-6) != 0 + || baz(17) != 1 + || qux(-128) != 0 + || foo(127) != 1) { + __builtin_abort(); + } + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr106243.c b/gcc/testsuite/gcc.dg/pr106243.c new file mode 100644 index 00000000000..ee2706f2bf9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr106243.c @@ -0,0 +1,43 @@ +/* PR tree-optimization/106243 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#define vector __attribute__((vector_size(4*sizeof(int)))) + +/* Test from PR. */ +__attribute__((noipa)) int foo (int x) { + return -x & 1; +} + +/* Other test from PR. */ +__attribute__((noipa)) int bar (int x) { + return (0 - x) & 1; +} + +/* Forward propogation. */ +__attribute__((noipa)) int baz (int x) { + x = -x; + return x & 1; +} + +/* Commutative property. */ +__attribute__((noipa)) int qux (int x) { + return 1 & -x; +} + +/* Vector test case. */ +__attribute__((noipa)) vector int waldo (vector int x) { + return -x & 1; +} + +/* Should not simplify. */ +__attribute__((noipa)) int thud (int x) { + return -x & 2; +} + +/* Should not simplify. */ +__attribute__((noipa)) int corge (int x) { + return -x & -1; +} + +/* { dg-final {scan-tree-dump-times "-" 2 "optimized" } } */