From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31653 invoked by alias); 13 Oct 2016 18:36:23 -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 31624 invoked by uid 89); 13 Oct 2016 18:36:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=inserts, unrolled, executions X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Oct 2016 18:36:22 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B75B84E33A; Thu, 13 Oct 2016 18:36:20 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-144.phx2.redhat.com [10.3.116.144]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9DIaIuf008298; Thu, 13 Oct 2016 14:36:20 -0400 Subject: Re: [PATCH] Don't peel extra copy of loop in unroller for loops with exit at end To: Pat Haugen , GCC Patches References: From: Jeff Law Message-ID: Date: Thu, 13 Oct 2016 18:36:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg01079.txt.bz2 On 09/22/2016 01:10 PM, Pat Haugen wrote: > I noticed the loop unroller peels an extra copy of the loop before it enters the switch block code to round the iteration count to a multiple of the unroll factor. This peeled copy is only needed for the case where the exit test is at the beginning of the loop since in that case it inserts the test 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, and therefore removes the need to always execute that first peeled copy. With this change, when the number of executions of the loop is an even multiple of the unroll factor then the code will jump to the unrolled loop immediately 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 size by removing a peeled copy of the loop. > > Bootstrap/regtest on powerpc64le with no new regressions. Ok for trunk? > > > > 2016-09-22 Pat Haugen > > * loop-unroll.c (unroll_loop_runtime_iterations): Condition initial > loop peel to loops with exit test at the beginning. > > OK. jeff