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 F16EE3858C62 for ; Tue, 26 Jul 2022 14:31:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F16EE3858C62 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-561-9ZyNLZtSP9-aC0gCi8p5cw-1; Tue, 26 Jul 2022 10:31:25 -0400 X-MC-Unique: 9ZyNLZtSP9-aC0gCi8p5cw-1 Received: by mail-pf1-f199.google.com with SMTP id d18-20020aa78692000000b0052abaa9a6bbso4805420pfo.2 for ; Tue, 26 Jul 2022 07:31:25 -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=dwVQEBa/Tw0x56Ujmg8hQcgbfYEBoEhlFvkEaluM6Z4=; b=J1R/ARjee//S4vzbpkmcIcKncRXeREJXjexEBH6/taMOFbu/RHOzcXqykF8XYYQ13U tRxbdYYe/BHcCmhrPPvyodu3e/2cKLP1AxRpCFOG5EtRCuNyw4bUQxGTIxg0vUhlGVWy dFDqAzjHcRP7lI5ULv6UD5uHYfdYEy7yhUO6zBYPTG7dTTDnII88/tOrN2f+VsjQxrw2 +tile+P7/GYIP2OVO9Dqwc8i+iQdEaVPBJJVsyXKKPGMFNzeFzCp6UIDFX81fjpX7yAz 1m4xgJxN8K34BitBPtH51kFA6Uzdw3gE0+raD6eUCSoQQ9f+9wMFIKO6/3NTlp5ORByM MDzA== X-Gm-Message-State: AJIora9Rf+V1F5JenkhvGSu6CcHDMQIP5hizaxe2NsdpGy1cwU1f9gHN 7BTR4SiximkZpxsmXH/nmZ3W5YxWeFKmzn0k+P5XWon3ivtNx877C0DkAWNlygebmIr6p/8yh6Y UU3hXRV9MWnwJpCVrbLHv8FcP+fwEW5MK1g== X-Received: by 2002:a17:902:7fc5:b0:16d:14bb:7298 with SMTP id t5-20020a1709027fc500b0016d14bb7298mr17578411plb.128.1658845884755; Tue, 26 Jul 2022 07:31:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sAjKyis16Db/C4FFRuHyOFlJ5PkFxrbRnNJRxDvEb563jLB7AmiP29HjQ3MpymBDFZI1KcEVggS/xiMrgxNGE= X-Received: by 2002:a17:902:7fc5:b0:16d:14bb:7298 with SMTP id t5-20020a1709027fc500b0016d14bb7298mr17578386plb.128.1658845884382; Tue, 26 Jul 2022 07:31:24 -0700 (PDT) MIME-Version: 1.0 References: <20220725193425.511903-1-sfeifer@redhat.com> In-Reply-To: From: Sam Feifer Date: Tue, 26 Jul 2022 10:31:13 -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: Tue, 26 Jul 2022 14:31:31 -0000 > > int f(_Complex int x, _Complex int y) > { > return x == x / y * y; > } > After some research about mod with complex types, I found that the binary mod operation does not work with complex types. If so, the complex test case should not be simplified. Is this correct? I should also note that the above function, f, causes a segmentation fault. I can only get a function with complex types to compile by breaking up the operations like I would in a forward propagation test case. When I do this, it does not simplify into mod, which I think is right. Thanks -Sam > 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 > >> > > >> > >