From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107220 invoked by alias); 6 Mar 2018 16:09:14 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 107211 invoked by uid 89); 6 Mar 2018 16:09:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=prathamesh.kulkarni@linaro.org, prathameshkulkarnilinaroorg, H*i:sk:CAHFci2, H*f:sk:CAHFci2 X-HELO: mail-lf0-f44.google.com Received: from mail-lf0-f44.google.com (HELO mail-lf0-f44.google.com) (209.85.215.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Mar 2018 16:09:12 +0000 Received: by mail-lf0-f44.google.com with SMTP id q69so29264915lfi.10 for ; Tue, 06 Mar 2018 08:09:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Io0kPXMBDAI6V+gXyvDjoNldTy7ZU0UE/5GrA5TZVZM=; b=Zr/zOBExR1lqbbnpYCNCdCEd+pLDzyoDuyQDnXblX8wqq5zaM9toplBtV8uzQMeK2T EPepG7bmNLmPtP/+IZeKRC6uNLzhyzHSb6horjHryFRkZHK6/vr60UyDWLbx2HEFKCxa PPW8Ufwee+FzpjonBU7q16/yGVNJepl7xT2JknILnoSs+rYZotb8Y+RcY0QAnHRJYL2b mYSleELcR9f9dvXhS4gfIgZUqY3o9TEnyWeSuMBj4Sqxxrt9QBuDZRnUaxOTa00dTOp8 VuZ44CyCDkKfgzThMFokU+jNqWXz+OFQRhls1xUJ2NyUCKIqrayqOeRYM6CL3S5CiF4S u8Ng== X-Gm-Message-State: APf1xPDZ6mzId2SvqXIPC7MmjMuRyeA+1OrfFPONHlmB0XRGXUGouLV3 9QcR0blDj2v8VjP34p31BCQHRZXD1OzKq0rpug4= X-Google-Smtp-Source: AG47ELt5rDbLYxcA6MRkhWQAvGLQYM2h07r5AEt+Jtn2XKk7EOllqTI94VOtEzfgUYoerlR+rWRgUYgEotnn3NwUx9c= X-Received: by 10.46.82.16 with SMTP id g16mr12882507ljb.67.1520352550124; Tue, 06 Mar 2018 08:09:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.46.104.4 with HTTP; Tue, 6 Mar 2018 08:09:09 -0800 (PST) In-Reply-To: References: From: Richard Biener Date: Tue, 06 Mar 2018 16:09:00 -0000 Message-ID: Subject: Re: eliminate dead stores across functions To: "Bin.Cheng" Cc: Prathamesh Kulkarni , GCC Development Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00072.txt.bz2 On Tue, Mar 6, 2018 at 4:50 PM, Bin.Cheng wrote: > On Tue, Mar 6, 2018 at 2:28 PM, Richard Biener > wrote: >> On Tue, Mar 6, 2018 at 1:00 PM, Prathamesh Kulkarni >> wrote: >>> Hi, >>> For the following test-case, >>> >>> int a; >>> >>> __attribute__((noinline)) >>> static void foo() >>> { >>> a = 3; >>> } >>> >>> int main() >>> { >>> a = 4; >>> foo (); >>> return a; >>> } >>> >>> I assume it's safe to remove "a = 4" since 'a' would be overwritten >>> by call to foo ? >>> IIUC, ipa-reference pass does mod/ref analysis to compute side-effects >>> of function call, >>> so could we perhaps use ipa_reference_get_not_written_global() in dse >>> pass to check if a global variable will be killed on call to a >>> function ? If not, I suppose we could write a similar ipa pass that >>> computes the set of killed global variables per function but I am not >>> sure if that's the correct approach. >> >> Do you think the situation happens often enough to make this worthwhile? > There is one probably more useful case. Program may use global flags > controlling > how it does (heavy) computation. Such flags are only set couple of > times in execution > time. It would be useful if we can (IPA) propagate flags into computation heavy > functions by versioning (if necessary). For example: > > int flag = 1; > void foo () > { > //heavy computation wrto to flag > } > void main() > { > flag = 2; > foo(); > flag = 1; > foo(); > } Yeah, libquantum does this. There's also related example from some SPEC fortran testcase: vodi foo() { static int initialized; static T data; if (!initialized) { data.x = 1; initialized = 1; } ... } where we want to constant propagate from data.x. IIRC I tried to work on this, not sure if I solved it yet... Richard. > Of course this may only be useful for LTO. > Thanks, > bin >> >> ipa-reference doesn't compute must-def, only may-def and may-use IIRC. >> >> Richard. >> >>> Thanks, >>> Prathamesh