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: 66954 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 973473858C2F for ; Mon, 27 Mar 2023 12:32:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 973473858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679920348; 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=Q/g+obpgBB0iFBUOON4BzqNhxDUh62FI4NWWovXlUdVnoPuRJnEEU1If61TLTCt6R 0n1Fv44iBwQxeocfJtD3+RFC1+AZmoYq2vipmtlX8vJl+y6OqNRIji5EKWvKFYE88w GrBAUlMDT9YE1P0NW33Gs2DBV/g1gB61x027cCzE= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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; +}