From patchwork Thu Nov 25 13:11:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 48132 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 3FBD3385841F for ; Thu, 25 Nov 2021 13:11:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3FBD3385841F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637845900; bh=Fq5drdvGr6dXfjW9QJcrVVFLhWTGdDWijkska6u/6eI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=MxnrruMU9NJuWo6luSdgKzRGLZJ18CMvfIECKYnSAzkOiolqdo5Uw7rfuXOoq/6EH mdnRN9oyZHq+eAcsYYqg0uJHQUO2GGNIWYyzxKEIwu15t7ApngQG0n4AG6XoB7w2HF Z+NeWc/fsq6FMavHOt8GS3hkrTu9R24kwGdMaPd8= 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 816053858D35 for ; Thu, 25 Nov 2021 13:11:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 816053858D35 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 45E3728099C; Thu, 25 Nov 2021 14:11:05 +0100 (CET) Date: Thu, 25 Nov 2021 14:11:05 +0100 To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: Do not check gimple_call_chain in tree-ssa-alias Message-ID: <20211125131105.GA85959@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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, this pach removes gimple_call_cahin checkin ref_maybe_used_by_call_p that disables check for CONST functions. I suppose it was meant to allow consts to read variables from the static chain but this is not what other places do. The testcase: int main() { int a =0; __attribute__ ((noinline,const)) int reta () { return a; } int val = reta(); a=1; return val+reta (); } Gets optimized to single call of reta since at least gcc 4.1. LTO bootstrapped and regtested x86_64-linux all languages. OK? * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Do not check gimple_call_call when treating const functions. diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index cd6a0b2f67b..3c253e2843f 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -2743,9 +2743,7 @@ ref_maybe_used_by_call_p_1 (gcall *call, ao_ref *ref, bool tbaa_p) unsigned i; int flags = gimple_call_flags (call); - /* Const functions without a static chain do not implicitly use memory. */ - if (!gimple_call_chain (call) - && (flags & (ECF_CONST|ECF_NOVOPS))) + if (flags & (ECF_CONST|ECF_NOVOPS)) goto process_args; /* A call that is not without side-effects might involve volatile