From patchwork Mon Mar 27 12:31:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 75389 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1474564vqo; Mon, 27 Mar 2023 05:32:49 -0700 (PDT) X-Google-Smtp-Source: AKy350aLDUNW70ftCgUGW5R9SDmw+Y3tySR478fecAXDHSx5OryjACgqr3wVCmObDge86ACt7R7R X-Received: by 2002:a17:906:f84e:b0:930:af80:5b9b with SMTP id ks14-20020a170906f84e00b00930af805b9bmr11447720ejb.1.1679920369739; Mon, 27 Mar 2023 05:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679920369; cv=none; d=google.com; s=arc-20160816; b=IupfCwnCXxQHSkjLH0Sa/6ozAxKyoSy+pZWQihiYSaqM1prHtBDCKzTz3pvGEW+eht NeMUEEGeT0+YMQ/hEkjsaEtxKVvOBvRDduqm1UK96o5rfrM6XwvTTdvu4Op2X2APMP7J gY4isrBVAAyPk47oGORL6UsyDvWSOPc8ys932MPceqKJK3ofcx4txb9C+noC0r+5I1EU D8MGI8tZSMtW6uLKgcHUqT3aWu1LwfQPaHHurky53qlXxkpfPsGh+CrSSujKQQzPZskl FarfumwnWIj+k7QYzO8tMu9dn9+etjCTPETX/iM//imomjB/CPjDZVfEQ0pvaLdSOlW6 LTGA== 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:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=3juKcpZfDcxCTLoNhGP05qYbLE+T+mgr+IDSiEnXSzk=; b=vyVqVq5rHQNR499C+EQbeg789ft2KYU2rms8d5llUDpMUh+ho3wcvT4JKQykizwdqJ vY3EbSByjxGBflCXeJlfK9em1n666M3ucYf3F9y+s6VbH0ymnlp0kquOoJM4glO3oaQh wWTDKfPASLtG9/xnbYrq91/DbEt4wrL6vNbx9yu5bYGt71ba6KOBzu8+TJaVHtpPRf3z Ily8bbzACgi67ILO/S+nycvJEEfg3VT7g+FyIZBNcq/0iA14iD4RHMyMcwK5B9VEspmV 3wW9h5LA6FKYbCrTb/eZF7TqJXB2kMyrfSzBUEBqWTfITwHOoFVCBlSoDAjWVl3CmsFW TzlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=wB33aGTE; 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 g24-20020aa7c598000000b005021f0d5759si8742352edq.672.2023.03.27.05.32.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 05:32:49 -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=wB33aGTE; 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 CDA4B3858039 for ; Mon, 27 Mar 2023 12:32:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CDA4B3858039 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679920364; bh=3juKcpZfDcxCTLoNhGP05qYbLE+T+mgr+IDSiEnXSzk=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=wB33aGTE660DeOARLfPrMHQGBJ8wMxbpz3mWUR7czQMcImd//4h9jLxGMjhFuZkQY r137pImDrd8Ik8mfY0tDm28aBE6On6T9h1CQGjJ01DgU2eHupZ8VnDRIxk5O9O082K geeHYoaxrcfOI9vaW/Yz24qKePjtpIARPrswj4Ho= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 4F1F7385840A for ; Mon, 27 Mar 2023 12:32:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F1F7385840A Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6E3691FDA8 for ; Mon, 27 Mar 2023 12:31:59 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5B75713482 for ; Mon, 27 Mar 2023 12:31:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iAHSFL+MIWRBTwAAMHmgww (envelope-from ) for ; Mon, 27 Mar 2023 12:31:59 +0000 Date: Mon, 27 Mar 2023 14:31:58 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/54498 - testcase for the bug MIME-Version: 1.0 Message-Id: <20230327123159.5B75713482@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761524181861422172?= X-GMAIL-MSGID: =?utf-8?q?1761524181861422172?= I realized I never added a testcase for the fix of this bug. Now done after verifying it still fails when reverting the fix. tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/54498 * g++.dg/torture/pr54498.C: New testcase. --- gcc/testsuite/g++.dg/torture/pr54498.C | 57 ++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 gcc/testsuite/g++.dg/torture/pr54498.C diff --git a/gcc/testsuite/g++.dg/torture/pr54498.C b/gcc/testsuite/g++.dg/torture/pr54498.C new file mode 100644 index 00000000000..74651f9063a --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr54498.C @@ -0,0 +1,57 @@ +// { dg-do run } +// { dg-additional-options "-fno-tree-sra" } + +#include + +using namespace std; + +class bar_src { + public: + bar_src() : next(0) {} + virtual ~bar_src() { delete next; } + + bar_src *next; +}; + +class foo_src : public bar_src { + public: + foo_src(double f, double fwidth, double s = 5.0); + virtual ~foo_src() {} + + private: + double freq, width, peak_time, cutoff; +}; + + +foo_src::foo_src(double f, double fwidth, double s) { + freq = f; width = 1/fwidth; cutoff = s*width; peak_time = cutoff; +} + +complex do_ft2(int i) __attribute__ ((noinline)); + +complex do_ft2(int i) { + return i == 0 ? complex(-491.697,887.05) : complex(-491.692,887.026); +} + +void foo(void) { + complex prev_ft = 0.0, ft = 0.0; + for (int i=0; i < 2; i++) { + prev_ft = ft; + { + foo_src src(1.0, 1.0 / 20); + ft = do_ft2(i); + } + if (i > 0) + { + double a = abs(ft - prev_ft); + if (a < 0.024 || a > 0.025) + __builtin_abort (); + } + } +} + +int main() +{ + foo(); + return 0; +}