From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id 5F3C23858CDA for ; Mon, 25 Jul 2022 21:14:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5F3C23858CDA Received: by mail-pj1-x1030.google.com with SMTP id y1so3502888pja.4 for ; Mon, 25 Jul 2022 14:14:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=x3lf1fNdKBt8UMzrvpzY8dnX1PTDKLn2cTPby82/G8M=; b=IZE8ST/U8N4Qcgoqo1m49D5LJ5pxswq9mpeMlj0KGoL4xWLpWeanxD9343O6hBcnwf sCAeJftWU0c1+GyvmGs5DEi/v1Hju2iSjkMDZ8LvPphKonebDcR9PXcErussaLJKw2/C EeklIVLFgOovbbljn8CRjNMFmHi3mJ1pN5NIfN/UdybYPMe7589B83CY1B/7wql39RTH Vu6FV2z8w0snsh1bIGZuB0wgZbNYz3eets49nTuRZgohkaxI09HbpDmeuXp7qgNKvoDp jg08dnX5fAGWuYY+Vk7f7cmr9J8xkKVMMiMdzduTSArt57HoFnp6MbYxjRAtXI3gMT03 bWJw== X-Gm-Message-State: AJIora+B7eTu7U0kGutuJwJjEhC3VKICcD/0xqIYNUUHyXB6lunUHTlL OMnY2FHqDRMfqiB+g3n/nZ49fMH7tZ4W6BJK9f4= X-Google-Smtp-Source: AGRyM1uMITbIv3x4RF92wHW4EkQ0v2j0pdkWq0a1CD9gJv/SzjF4l+LeQ5hdmqjjJnci4kMJ1OhHQSpWGI81mggiJ/g= X-Received: by 2002:a17:902:cf09:b0:16d:3b47:d2dc with SMTP id i9-20020a170902cf0900b0016d3b47d2dcmr13879777plg.123.1658783697217; Mon, 25 Jul 2022 14:14:57 -0700 (PDT) MIME-Version: 1.0 References: <20220725193425.511903-1-sfeifer@redhat.com> In-Reply-To: From: Andrew Pinski Date: Mon, 25 Jul 2022 14:14:44 -0700 Message-ID: Subject: Re: [PATCH] match.pd: Add new division pattern [PR104992] To: Sam Feifer Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2022 21:15:02 -0000 On Mon, Jul 25, 2022 at 1:59 PM Sam Feifer wrote: > > >> I suspect for eq and mult you might want to add :c to them even though >> in your testcase you don't need them, you might be able to get it via >> using different statements and looking at the forwprop gimple dump. >> Also, did you send the wrong patch as it looks like the function call >> to build_zero_cst has been eaten ... (or is it just because TREE_TYPE >> has parentheses inside the macro and it just accidently works :)). > > > I got lucky and it works without parentheses :). I just added them in for readability. > >> You might also want to make sure it does the right thing for vector >> types and complex types (yes both are valid for trunc_div still). >> > > I made a vector test case, but it's giving me errors when using " == " between two vectors. I'm running it with the C++ front end and it's saying the return value cannot be converted. Any tips for this? > > I'm not sure exactly what you mean by "complex types" in terms of testing this patch. Could I get an example? int f(_Complex int x, _Complex int y) { return x == x / y * y; } For vector try (which works for both the C and C++ front-end): #define vector __attribute__((vector_size(4*sizeof(int)) )) vector int f(vector int x, vector int y) { return x == x / y * y; } That is for the vector case, == still returns a vector type. Thanks, Andrew Pinski > > Thanks > -Sam > >> Thanks, >> Andrew Pinski >> >> > diff --git a/gcc/testsuite/gcc.dg/pr104992-1.c b/gcc/testsuite/gcc.dg/pr104992-1.c >> > new file mode 100644 >> > index 00000000000..a80e5e180ce >> > --- /dev/null >> > +++ b/gcc/testsuite/gcc.dg/pr104992-1.c >> > @@ -0,0 +1,30 @@ >> > +/* PR tree-optimization/104992 */ >> > +/* { dg-do run } */ >> > +/* { dg-options "-O2"} */ >> > + >> > +#include "pr104992.c" >> > + >> > +int main () { >> > + >> > + /* Should be true. */ >> > + if (!foo(6, 3) >> > + || !bar(12, 2) >> > + || !baz(34, 17) >> > + || !qux(50, 10) >> > + || !fred(16, 8) >> > + || !baz(-9, 3) >> > + || !baz(9, -3) >> > + || !baz(-9, -3) >> > + ) { >> > + __builtin_abort(); >> > + } >> > + >> > + /* Should be false. */ >> > + if (foo(5, 30) >> > + || bar(72, 27) >> > + || baz(42, 15)) { >> > + __builtin_abort(); >> > + } >> > + >> > + return 0; >> > +} >> > diff --git a/gcc/testsuite/gcc.dg/pr104992.c b/gcc/testsuite/gcc.dg/pr104992.c >> > new file mode 100644 >> > index 00000000000..b4b0ca53118 >> > --- /dev/null >> > +++ b/gcc/testsuite/gcc.dg/pr104992.c >> > @@ -0,0 +1,35 @@ >> > +/* PR tree-optimization/104992 */ >> > +/* { dg-do compile } */ >> > +/* { dg-options "-O2 -fdump-tree-optimized" } */ >> > + >> > +/* Form from PR. */ >> > +__attribute__((noipa)) unsigned foo(unsigned x, unsigned y) >> > +{ >> > + return x / y * y == x; >> > +} >> > + >> > +__attribute__((noipa)) unsigned bar(unsigned x, unsigned y) { >> > + return x == x / y * y; >> > +} >> > + >> > +/* Signed test case. */ >> > +__attribute__((noipa)) unsigned baz (int x, int y) { >> > + return x / y * y == x; >> > +} >> > + >> > +/* Changed order. */ >> > +__attribute__((noipa)) unsigned qux (unsigned x, unsigned y) { >> > + return y * (x / y) == x; >> > +} >> > + >> > +/* Wrong order. */ >> > +__attribute__((noipa)) unsigned fred (unsigned x, unsigned y) { >> > + return y * x / y == x; >> > +} >> > + >> > +/* Wrong pattern. */ >> > +__attribute__((noipa)) unsigned waldo (unsigned x, unsigned y, unsigned z) { >> > + return x / y * z == x; >> > +} >> > + >> > +/* { dg-final {scan-tree-dump-times " % " 4 "optimized" } } */ >> > >> > base-commit: 633e9920589ddfaf2d6da1c24ce99b18a2638db4 >> > -- >> > 2.31.1 >> > >>