From patchwork Thu Nov 11 13:40:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1553929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=KU+uMclA; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HqjYG6lZWz9s1l for ; Fri, 12 Nov 2021 00:41:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2AC863857C56 for ; Thu, 11 Nov 2021 13:41:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2AC863857C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636638079; bh=QWB6fJ5mpgmHgYH40SUlqxQUEjsSFRFITTgzFS2EcGs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=KU+uMclA+PC/fZ8XTP4dINkfNtKLko6R+St0Gy9076cbY6k+whfnumFe+PAgTkmcT ZTp5zdoGjk30Yw+IlwGSXuLv2iT047OoEPVEfzcF1ldlMn++fpp2mTc48ktEa8iO8C W3Y/fUsX1oui4pZCENQlkFkjVeIQppV2QQ81sf7A= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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-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-Patchwork-Original-From: Jan Hubicka via Gcc-patches From: Jan Hubicka Reply-To: Jan Hubicka Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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",