From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 2B136385840A for ; Thu, 11 Nov 2021 13:40:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2B136385840A Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 18B7C2808F8; Thu, 11 Nov 2021 14:40:37 +0100 (CET) Date: Thu, 11 Nov 2021 14:40:37 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix recursion discovery in ipa-pure-const Message-ID: <20211111134037.GF17431@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Thu, 11 Nov 2021 13:40:39 -0000 Hi, We make self recursive functions as looping of fear of endless recursion. This is done correctly for local pure/const and for non-trivial SCCs in callgraph, but for trivial SCCs we miss the flag. I think it is bad decision since infinite recursion will run out of stack, but changing it upsets some testcases and should be done independently. So this patch is fixing current behaviour to be consistent. Bootstrapped/regtested x86_64-linux, comitted. gcc/ChangeLog: 2021-11-11 Jan Hubicka * ipa-pure-const.c (propagate_pure_const): Self recursion is a side effects. diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index 505ed4f8a3b..64777cd2d91 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -1513,6 +1611,9 @@ propagate_pure_const (void) enum pure_const_state_e edge_state = IPA_CONST; bool edge_looping = false; + if (e->recursive_p ()) + looping = true; + if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, " Call to %s",