From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96138 invoked by alias); 28 Nov 2016 13:36:57 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 96073 invoked by uid 89); 28 Nov 2016 13:36:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=gross, coarse, hum X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 28 Nov 2016 13:36:39 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C3AC5AABE; Mon, 28 Nov 2016 13:36:36 +0000 (UTC) Date: Mon, 28 Nov 2016 13:36:00 -0000 From: Richard Biener To: Pitchumani Sivanupandi cc: law@redhat.com, GCC Patches Subject: Re: [RFC, tentative patch] Adjust cost for conversion expression In-Reply-To: <9867b701-9236-b03e-d8b5-11fc383c60a0@microchip.com> Message-ID: References: <90583097-cd60-0152-66a5-e32d6830b776@microchip.com> <9867b701-9236-b03e-d8b5-11fc383c60a0@microchip.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2016-11/txt/msg02764.txt.bz2 On Mon, 28 Nov 2016, Pitchumani Sivanupandi wrote: > On Thursday 24 November 2016 04:54 PM, Richard Biener wrote: > > On Thu, 24 Nov 2016, Pitchumani Sivanupandi wrote: > > > > > GCC inlines small functions if the code size after expansion is not > > > excedded. > > > For test case (inline.c, avr-gcc -Os -S inline.c) code size become higher > > > if > > > 'func2' is inlined. It happens because the CONVERT_EXPR/ NOP_EXPR are > > > considered > > > as zero cost expression. > > > > > > Few conversions will cost additional instructions. For targets like AVR > > > it will cost considerably as it's register size is just one byte. > > > > > > Attached the tentative patch that changes the CONVERT_EXPR/ NOP_EXPR cost > > > to 1 if the LHS is bigger than RHS and target's word_mode. > > > > > > Is this Ok? > > > > > > Would it be reasonable if cost evaluated as below instead of constant 1? > > > if (LHS PRECISION > RHS PRECISION) > > > cost = LHS_PRECISION / word_mode - 1 > > > else > > > cost = 0 > > > > > > Built GCC for native with bootstrap enabled. No issues. > > I believe a better check would be tree_nop_conversion_p (). Thus > > > > CASE_CONVERT: > > return tree_nop_conversion_p (type, TREE_TYPE (op0)) ? 0 : 1; > > > > note that > > > > + rhs_code = gimple_assign_rhs_code (stmt); > > + if ((rhs_code == NOP_EXPR) || (rhs_code == CONVERT_EXPR)) > > + { > > + cost += estimate_operator_cost (rhs_code, weights, > > + gimple_assign_lhs (stmt), > > + gimple_assign_rhs1 (stmt)); > > + } > > > > is super-ugly - please simply add the type of the expression as an > > additional argument (see gimple_expr_type (), but the type of the > > LHS would do as well). > > > > Note that doing this change might require some re-tuning of > > inliner params, but otherwise it's totally sensible. > > Thanks. Attached the revised patch. > > When reg-tested for x86_64 found following failures. > FAIL: gcc.dg/uninit-19.c > FAIL: gcc.dg/vect/vect-104.c > > For uninit-19.c, index to dereference float array is converted to > long unsigned int and that is not tree_nop_conversion_p. This caused > function cost to increase and auto inline is rejected. Hum, yeah... so the simple tree_nop_conversion_p is too coarse... (the conversions do result in code generation though). > I think, this may be huge penalty for target like x86_64 which has rich ISA. > Any suggestions to avoid hitting such targets? No good one. estimate_num_insns is really just a wild guess ... but one with a huge impact downstream. Note we're not trying to be clever anywhere but we even do not handle "gross" mistakes like counting vector additions of 2048 element vectors (later split to HW supportable sizes) as one. Yes, we're trying to be clever at call stmts, but that's it. Richard.