From patchwork Mon Jul 22 16:39:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pchang9@cs.wisc.edu X-Patchwork-Id: 260761 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 4E9982C009A for ; Tue, 23 Jul 2013 02:40:19 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:subject:from:to:mime-version:content-type; q= dns; s=default; b=UAFsPlkaZhcIWgQFirnR0QqOm4XkXRVxluUVokGk0wLrn4 AmqIvfBabqbI+9g1kR5vXoSwREemWSctWoSFXTMl52vKwBUqUkw52iFtFL6VFI9x UUltZE/PQagJEHbCCQoyzlj66nBzXrylxtnjsS64vzNeXuSfyaSUbZkMrNGVY= 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 :message-id:date:subject:from:to:mime-version:content-type; s= default; bh=DPe1SPOCtpJDOPrj32LoVNTQSY8=; b=ClAMiSYlvWJ4qh+Y2nmt xnOESTKnzVBDwEemsuVHhDp1aBjJGYAxT04SG0gxaI3XuS8K0WDJk02WIqkrcKIv ci4a8Mf9KArBUW+umOfEwfhLElRbaVxC9/pOFY9oodp6Q2+yWE12A6fKwL+uQv8D adcN3bdrZeKtwIb58tIOqXA= Received: (qmail 20262 invoked by alias); 22 Jul 2013 16:40:13 -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 20234 invoked by uid 89); 22 Jul 2013 16:40:13 -0000 X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_20, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_W, RDNS_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from Unknown (HELO sandstone.cs.wisc.edu) (128.105.6.39) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 22 Jul 2013 16:39:45 +0000 Received: from webmail.cs.wisc.edu (george.cs.wisc.edu [128.105.7.110]) by sandstone.cs.wisc.edu (8.14.1/8.14.1) with ESMTP id r6MGdbBw014075 for ; Mon, 22 Jul 2013 11:39:38 -0500 Received: from 72.33.255.231 (SquirrelMail authenticated user pchang9) by webmail.cs.wisc.edu with HTTP; Mon, 22 Jul 2013 11:39:38 -0500 Message-ID: Date: Mon, 22 Jul 2013 11:39:38 -0500 Subject: [Patch, PR 57811] Wasted work in find_reloads() From: pchang9@cs.wisc.edu To: gcc-patches@gcc.gnu.org User-Agent: SquirrelMail/1.4.22 MIME-Version: 1.0 X-Virus-Found: No Hi, The problem appears in revision 201034 in version 4.9. I attached one-line patches that fixes it. I also reported this problem at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57811 Bootstrap and regression-tested on x86_64-linux. In method "find_reloads()" in gcc/reload.c, the loop on line 3324 should break immediately after "badop" is set to "1". Also, the loop on line 4641 should break after "ok" is set to "0". 2013-07-22 Chang * reload.c (find_reloads): Exit loop once we find this operand cannot be reloaded somehow for this alternative. * reload.c (find_reloads): Exit loop once we find a hard register. -Chang Index: gcc/reload.c =================================================================== --- gcc/reload.c (revision 201034) +++ gcc/reload.c (working copy) @@ -3324,7 +3324,10 @@ for (j = 0; j < i; j++) if (this_alternative_matches[j] == this_alternative_matches[i]) - badop = 1; + { + badop = 1; + break; + } break; case 'p': Index: gcc/reload.c =================================================================== --- gcc/reload.c (revision 201034) +++ gcc/reload.c (working copy) @@ -4640,7 +4640,10 @@ for (nri = 1; nri < nr; nri ++) if (! TEST_HARD_REG_BIT (reg_class_contents[rld[i].rclass], regno + nri)) - ok = 0; + { + ok = 0; + break; + } if (ok) rld[i].reg_rtx = dest; Index: gcc/reload.c =================================================================== --- gcc/reload.c (revision 201034) +++ gcc/reload.c (working copy) @@ -3324,7 +3324,10 @@ for (j = 0; j < i; j++) if (this_alternative_matches[j] == this_alternative_matches[i]) - badop = 1; + { + badop = 1; + break; + } break; case 'p': Index: gcc/reload.c =================================================================== --- gcc/reload.c (revision 201034) +++ gcc/reload.c (working copy) @@ -4640,7 +4640,10 @@ for (nri = 1; nri < nr; nri ++) if (! TEST_HARD_REG_BIT (reg_class_contents[rld[i].rclass], regno + nri)) - ok = 0; + { + ok = 0; + break; + } if (ok) rld[i].reg_rtx = dest;