From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 114743858CDA for ; Mon, 25 Jul 2022 20:59:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 114743858CDA Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-103-V8TJ1ln2OjaEAoev4TsQvg-1; Mon, 25 Jul 2022 16:59:31 -0400 X-MC-Unique: V8TJ1ln2OjaEAoev4TsQvg-1 Received: by mail-pf1-f197.google.com with SMTP id x34-20020a056a000be200b0052b7f102681so4018818pfu.5 for ; Mon, 25 Jul 2022 13:59:31 -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=2BCRmCHZ8XhK1i/WJdbzIZy2piLxSZs4IgdHPXH6Dd4=; b=awfThq3GwHbSmd7PeqbcRhlcGPhu68BZooZ4/Ud5OVxZWAGvq61q17Z+rdtVPtOZlF aHaQSdP2hpcPvLQg6avkmQAoZfR282xKyLYpeyhsbv7Zx2M8PsOC5pCrJyRhA6xNL/OV XdRCvFzCF303H03tkW4NJmdBPL7aVIS4VFGpOwn7RfE38pRTgP+VhWj8nMGCotOqeBTI GcMxuee99Tk7V+NaeNd2tdlGnDtB1wDEf2MQT4LHDVCIpyLRC+806eYbBUJYKjD1fxYB 0bFEr2j8ANgOJ91cvt/EfE7mCi1nMJO5cZPDPVfOnD4KAraSq7fvsZ9wzXNDDx4iFDbL yFkA== X-Gm-Message-State: AJIora8H91G+AiLbK80U6vaDV4F1JEYyfFgkrjtmYZPT1XqbTiulRKbG Njtu7bijpjyjQoha1yLYcuS7b+9GduO7mT/UBRv2dQr9+NcrgpuVjpdmohZNE/d3CKBU1TETP3j NxnhtOChTCozmz0CkqWGJIr6ONBuyJDjIsw== X-Received: by 2002:a17:903:18a:b0:16c:4f75:7297 with SMTP id z10-20020a170903018a00b0016c4f757297mr13733926plg.133.1658782770837; Mon, 25 Jul 2022 13:59:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s0jNd/tXOFUGtyYM1bty6nmK9qg9NGVrtJ4MsvAgEx03nQB/AwThHAm1HSpkld3wPgeqyjCXzqHEAKGA/IXuk= X-Received: by 2002:a17:903:18a:b0:16c:4f75:7297 with SMTP id z10-20020a170903018a00b0016c4f757297mr13733907plg.133.1658782770530; Mon, 25 Jul 2022 13:59:30 -0700 (PDT) MIME-Version: 1.0 References: <20220725193425.511903-1-sfeifer@redhat.com> In-Reply-To: From: Sam Feifer Date: Mon, 25 Jul 2022 16:59:19 -0400 Message-ID: Subject: Re: [PATCH] match.pd: Add new division pattern [PR104992] To: Andrew Pinski Cc: GCC Patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, 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 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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 20:59:36 -0000 > 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? 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 > > > >