From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 67150 invoked by alias); 23 May 2018 09:47:15 -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 67118 invoked by uid 89); 23 May 2018 09:47:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1792, H*r:sk:a15-v6s, H*f:sk:50B057F, H*i:sk:50B057F X-HELO: mail-wr0-f194.google.com Received: from mail-wr0-f194.google.com (HELO mail-wr0-f194.google.com) (209.85.128.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 May 2018 09:47:13 +0000 Received: by mail-wr0-f194.google.com with SMTP id a15-v6so17998257wrm.0 for ; Wed, 23 May 2018 02:47:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8mQRJF2uFUZM5mhcBEBmII/OUFqLwm1+C9n4oI2hJLk=; b=gkniPqxFGi0GMiEzm48dzVMpr6bVt++fgwlhSHb3DTfg533xnlmcRDOFDJ1x3CYqjg rknYMvHIykPiJykoG8p4aUasYWkT7l4++jICVyOZ4M3E7QMNd04pyeEJJT22P+KKIMAU Lsmka6Gg3xXI6WkyXOoK73B0C/+UBed2SEp+iQyO3ybAIceE7igO7aY8EYkO9azVW9Ft ds2T43w3Qbf7r5PF4xwhiiRLXtaFYAj4kxOyJEHA2BXPCpTYLGwk2aVK/TFnRPCwxzHn Ruxss6EIi5llz2vVpv0dYJHHGIskJETc1rWz6HFqSAbIfwdAnj7O61u+05rn7gtNaZeq 6tKA== X-Gm-Message-State: ALKqPwep3+X2zvvwsZgqth7q5OOyphgLNZBp2/LG7pPcqW/QWCPLZtsh 2nWQZYe6IX0RLa1GZurl4m4bqclOmAQUryC3GeI= X-Google-Smtp-Source: AB8JxZqaCf350yNByYD5mUiJNgwsciTgkRDkgwpEQzYi7gs29UMEZGJDvimnt4L98vdnl+2dw61ChNZkFmKnGYIpdeQ= X-Received: by 2002:a19:9e12:: with SMTP id h18-v6mr1210954lfe.101.1527068830975; Wed, 23 May 2018 02:47:10 -0700 (PDT) MIME-Version: 1.0 References: <018C29D6-6245-4D31-B43B-623E080A6F87@comcast.net> <20180522192609.GQ17342@gate.crashing.org> <50B057F6-F0AB-4213-91DE-2A988C72436F@comcast.net> In-Reply-To: <50B057F6-F0AB-4213-91DE-2A988C72436F@comcast.net> From: Richard Biener Date: Wed, 23 May 2018 09:47:00 -0000 Message-ID: Subject: Re: How do I stop gcc from loading data into registers when that's not needed? To: paulkoning@comcast.net Cc: Segher Boessenkool , GCC Development Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-05/txt/msg00203.txt.bz2 On Wed, May 23, 2018 at 2:50 AM Paul Koning wrote: > > On May 22, 2018, at 3:26 PM, Segher Boessenkool < segher@kernel.crashing.org> wrote: > > > > > > -fdump-rtl-combine-all (or just -da or -dap), and then look at the dump > > file. Does combine try this combination? If so, it will tell you what > > the resulting costs are. If not, why does it not try it? > > > >> Sorry, I'm not very familiar with this area of GCC either. Did you confirm > >> that combine at least tries to merge the memory ops into the instruction? > > > > It should, it's a simple reg dependency. In many cases it will even do > > it if it is not single-use (via a 3->2 combination). > I examined what gcc does with two simple functions: > void c2(void) > { > if (x < y) > z = 1; > else if (x != y) > z = 42; > else > z = 9; > } > void c3(void) > { > if (x < y) > z = 1; > else > z = 9; > } > Two things popped out. > 1. The original RTL (from the expand phase) has a memory->register move for x and y in c2, but it doesn't for c3 (it simply generates a memory/memory compare there). What triggers the different choice in that phase? > 2. The reported costs for the various insns are > r22:HI=['x'] 6 > cmp(r22:HI,r23:HI) 4 > cmp(['x'],['y']) 16 > so the added cost for the memory argument in the cmp is 6 -- the same as the whole cost for the mov. That certainly explains the behavior. It isn't what I want it to be. Which target hook(s) are involved in these numbers? I don't see them in my rtx_costs hook. The rtx_cost hook. I think the costs above make sense. There's also a new insn_cost hook but you have to dig whether combine uses that. Otherwise address_cost might be involved. Richard. > paul