From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53987 invoked by alias); 15 Oct 2016 03:29:10 -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 53963 invoked by uid 89); 15 Oct 2016 03:29:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=pinskia@gmail.com, pinskiagmailcom, Hx-languages-length:1874, pthaugen@linux.vnet.ibm.com X-HELO: mail-yw0-f174.google.com Received: from mail-yw0-f174.google.com (HELO mail-yw0-f174.google.com) (209.85.161.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 15 Oct 2016 03:29:08 +0000 Received: by mail-yw0-f174.google.com with SMTP id t193so86088127ywc.2 for ; Fri, 14 Oct 2016 20:29:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=WCVXehGemzV+8V3R9T9INF99B9X65seyjK5YKxWsIGw=; b=QjUfwjqtAJGObeIDyLTi6a+WvNZhvVfjIbTsTJlJPOd268c9WBUy6e5YVdvqU07A23 ANnZz32orZnLlTxV3yBHvDngu7J4TEXKjYUktExt9QBNbSeKmIOnrCnhGg7R37F70Cmm jG/lg9Peb0eP1Nzqtcr/UKwcKZfM547jBJUsqNniXuuyIfQWxh87zFMYFLTE8ddpXanS 8UFAYKXigO7FkWSesTdNheZoDo4QN+2vxcq2o6ht/m/d/hqWDW6dsWaJmNXA9Kjd3rVG ap0SSg+jVDBn6mDxoY7SWRvonMZUgyFTCNVWjesRfY50lEgEdVLHwoEe9y6co4raTk1r Bc4g== X-Gm-Message-State: AA6/9RlYr9/ofBibYpRMYaXuS4Kj7A8mSzXXUZl8EDSY8SlJfR9/56Vo5khV/axxlH10ZuBOcRs4SpEqs/tZ2g== X-Received: by 10.129.155.129 with SMTP id s123mr13168329ywg.194.1476502146453; Fri, 14 Oct 2016 20:29:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.76.78 with HTTP; Fri, 14 Oct 2016 20:29:05 -0700 (PDT) In-Reply-To: References: From: Andrew Pinski Date: Sat, 15 Oct 2016 03:29:00 -0000 Message-ID: Subject: Re: [PATCH] Don't peel extra copy of loop in unroller for loops with exit at end To: Pat Haugen Cc: GCC Patches Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg01224.txt.bz2 On Fri, Oct 14, 2016 at 8:28 PM, Andrew Pinski wrote: > On Thu, Sep 22, 2016 at 12:10 PM, Pat Haugen > wrote: >> I noticed the loop unroller peels an extra copy of the loop before it en= ters the switch block code to round the iteration count to a multiple of th= e unroll factor. This peeled copy is only needed for the case where the exi= t test is at the beginning of the loop since in that case it inserts the te= st for zero peel iterations before that peeled copy. >> >> This patch bumps the iteration count by 1 for loops with the exit at the= end so that it represents the number of times the loop body is executed, a= nd therefore removes the need to always execute that first peeled copy. Wit= h this change, when the number of executions of the loop is an even multipl= e of the unroll factor then the code will jump to the unrolled loop immedia= tely instead of executing all the switch code and peeled copies of the loop= and then falling into the unrolled loop. This change also reduces code siz= e by removing a peeled copy of the loop. >> >> Bootstrap/regtest on powerpc64le with no new regressions. Ok for trunk? > > This patch or > PR rtl-optimization/68212 > * cfgloopmanip.c (duplicate_loop_to_header_edge): Use preheader edge > frequency when computing scale factor for peeled copies. > * loop-unroll.c (unroll_loop_runtime_iterations): Fix freq/count > values for switch/peel blocks/edges. > > Caused a ~2.7-3.5% regression in coremarks with -funroll-all-loops. I should say on ThunderX (aarch64-linux-gnu). Thanks, Andrew > > Thanks, > Andrew > >> >> >> >> 2016-09-22 Pat Haugen >> >> * loop-unroll.c (unroll_loop_runtime_iterations): Condition init= ial >> loop peel to loops with exit test at the beginning. >> >>