From patchwork Fri Jan 13 13:28:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 91425 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp136629obz; Fri, 13 Jan 2017 05:29:06 -0800 (PST) X-Received: by 10.98.16.7 with SMTP id y7mr22637453pfi.55.1484314146030; Fri, 13 Jan 2017 05:29:06 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b3si12760513pll.166.2017.01.13.05.29.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jan 2017 05:29:06 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-446086-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-446086-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-446086-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Xh7k6F51ReXRrQtlQho6kJgUQs8kTLfbunLATQ4sFhMjCknTVZ ydR9hQKfGjC/StC9KlgNEgBSE6mzwhUYTxFa0J5LRmaUOeY4DjAImnkVIJYVqnri kQT88cR+esGbRLBAN7X/s3TRT2h5moe1ClBL6P2C/jFIzPfd/DFsyLrOQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=R77WwtbOgTjYAc5Hzt4G24Is3Uk=; b=KeUlVhDNc+u5ehcFxVUf aLN8VbIu85r9oVzGopB0kEglhIYb32WP68WvnLnKKb/+AgADmMtoFSzo9X7pZX9Q F6GmQktqKOqd/G7VRvsAHR7fiU1m6JfmCDNmh/EzLOHgHVqAjyM0tA1bAMiOjedK vY1CQrxmxzfNqGYf5HBUOCY= Received: (qmail 21794 invoked by alias); 13 Jan 2017 13:28:53 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 21780 invoked by uid 89); 13 Jan 2017 13:28:52 -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, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=speed_p, sk:slow_by, predictable_p, sk:SLOW_BY X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.216) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Jan 2017 13:28:42 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT3ol15ykJcYwTPLBCxG2PQt7BpWLF2I= X-RZG-CLASS-ID: mo00 Received: from [192.168.0.123] (ip5f5871bb.dynamic.kabel-deutschland.de [95.88.113.187]) by smtp.strato.de (RZmta 39.11 DYNA|AUTH) with ESMTPSA id 90674ft0DDSccp7 (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Fri, 13 Jan 2017 14:28:38 +0100 (CET) To: gcc-patches Cc: Denis Chertykov , Senthil Kumar Selvaraj From: Georg-Johann Lay Subject: [patch,avr]: Increase branch costs after reload. Message-ID: <65530b17-1c1a-ca6b-e6b9-5f4dcb7b006d@gjlay.de> Date: Fri, 13 Jan 2017 14:28:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 X-IsSubscribed: yes This adds a penalty of 4 to the post-reload branch costs. Purpose is reduce the number of out-of-line blocks like in unsigned long variant5 (unsigned in) { unsigned long out = 0; if (in & (1 << 0)) out |= 0xful << (4*0); if (in & (1 << 1)) out |= 0xful << (4*1); if (in & (1 << 2)) out |= 0xful << (4*2); if (in & (1 << 3)) out |= 0xful << (4*3); return out; } without the patch, code is variant5: mov r18,r24 ; 67 movqi_insn/1 [length = 1] sbrs r24,0 ; 10 *sbrx_branchhi [length = 2] rjmp .L6 ldi r22,lo8(15) ; 5 *movsi/5 [length = 4] ldi r23,0 ldi r24,0 ldi r25,0 .L2: .L6: ldi r22,0 ; 4 *movsi/2 [length = 3] ldi r23,0 movw r24,r22 rjmp .L2 ; 74 jump [length = 1] and with the patch it reads: variant5: mov r18,r24 ; 67 movqi_insn/1 [length = 1] ldi r22,lo8(15) ; 5 *movsi/5 [length = 4] ldi r23,0 ldi r24,0 ldi r25,0 sbrc r18,0 ; 10 *sbrx_branchhi [length = 2] rjmp .L2 ldi r22,0 ; 4 *movsi/2 [length = 3] ldi r23,0 movw r24,r22 .L2: Using fall-through safes insn 74. Main blocker for not increasing default branch costs in general is do_store_flag which is a heap of assertions not using rtx_costs and which gives the best results with the old default of 0, which is not changed. Tested without regressions. Ok for trunk? Johann * config/avr/avr.h (BRANCH_COST) [reload_completed]: Increase by 4. Index: config/avr/avr.h =================================================================== --- config/avr/avr.h (revision 244001) +++ config/avr/avr.h (working copy) @@ -360,7 +360,12 @@ typedef struct avr_args } \ } while (0) -#define BRANCH_COST(speed_p, predictable_p) avr_branch_cost +/* We increase branch costs after reload in order to keep basic-block + reordering from introducing out-of-line jumps and to prefer fall-through + edges instead. The default branch costs are 0, mainly because otherwise + do_store_flag might come up with bloated code. */ +#define BRANCH_COST(speed_p, predictable_p) \ + (avr_branch_cost + (reload_completed ? 4 : 0)) #define SLOW_BYTE_ACCESS 0