From patchwork Thu May 29 17:38:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 353814 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A87091400A0 for ; Fri, 30 May 2014 03:38:33 +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:from:mime-version:to:subject:content-type; q= dns; s=default; b=VX8hJ14dTRzp/WxJC8YCjmfZfr14KNYKIKPr3N+i/FGGbi HNEwN/c2IDdFpqhhx0lRL3tM9DhTPbSEXU+kfjA7cnIYZlDMEXrQ9hGp3kOigfhu CbRyabPKwlUTX7odpYfXDtCL9pARsNXbGVxXE9eE5RxSCGq23pl9bm7r8swDQ= 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:from:mime-version:to:subject:content-type; s= default; bh=jhu8yvFoL1NCkQnu0m/5KK7+Fnc=; b=klY9POEBBQVFSidlBS0c H37rr0qVS5Y/Hv/xPT9Z67rPESbeNEbskKEUbbBItds56BrvBLjCBwacmOjnCMDG Pv+acWft4DhbVIlNmh83prRlDL2yhSpCbDAt0WGv1w5fnxwgasKXCPeHLmbpqvMa oSsAhJM8MZ5ZRoZeHXHFgOM= Received: (qmail 15421 invoked by alias); 29 May 2014 17:38:26 -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 15408 invoked by uid 89); 29 May 2014 17:38:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 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, 29 May 2014 17:38:24 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4THcM0N015937 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 29 May 2014 13:38:23 -0400 Received: from topor.usersys.redhat.com ([10.15.16.142]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4THcMmL030347 for ; Thu, 29 May 2014 13:38:22 -0400 Message-ID: <5387708E.5020005@redhat.com> Date: Thu, 29 May 2014 13:38:22 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: gcc-patches Subject: patch to fix PR61325 X-IsSubscribed: yes The following patch PR61325. The details can be found on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61325 The patch was bootstrapped and tested on x86/x86-64. Committed as rev. 211060 to gcc-4.9 branch and as rev.211061 to trunk. 2014-05-29 Vladimir Makarov PR rtl-optimization/61325 * lra-constraints.c (process_address): Rename to process_address_1. (process_address): New function. 2014-05-29 Vladimir Makarov PR rtl-optimization/61325 * gcc.target/aarch64/pr61325.c: New. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 210973) +++ lra-constraints.c (working copy) @@ -2784,9 +2784,14 @@ Add reloads to the lists *BEFORE and *AFTER. We might need to add reloads to *AFTER because of inc/dec, {pre, post} modify in the - address. Return true for any RTL change. */ + address. Return true for any RTL change. + + The function is a helper function which does not produce all + transformations which can be necessary. It does just basic steps. + To do all necessary transformations use function + process_address. */ static bool -process_address (int nop, rtx *before, rtx *after) +process_address_1 (int nop, rtx *before, rtx *after) { struct address_info ad; rtx new_reg; @@ -2986,6 +2991,18 @@ return true; } +/* Do address reloads until it is necessary. Use process_address_1 as + a helper function. Return true for any RTL changes. */ +static bool +process_address (int nop, rtx *before, rtx *after) +{ + bool res = false; + + while (process_address_1 (nop, before, after)) + res = true; + return res; +} + /* Emit insns to reload VALUE into a new register. VALUE is an auto-increment or auto-decrement RTX whose operand is a register or memory location; so reloading involves incrementing that location. @@ -3270,7 +3287,7 @@ change_p = true; lra_update_dup (curr_id, i); } - + if (change_p) /* If we've changed the instruction then any alternative that we chose previously may no longer be valid. */ Index: testsuite/gcc.target/aarch64/pr61325.c =================================================================== --- testsuite/gcc.target/aarch64/pr61325.c (revision 0) +++ testsuite/gcc.target/aarch64/pr61325.c (working copy) @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +typedef unsigned int wchar_t; +typedef long unsigned int size_t; + +size_t +wcstombs(char *s , const wchar_t *pwcs , size_t n) +{ + int count = 0; + + if (n != 0) { + do { + if ((*s++ = (char) *pwcs++) == 0) + break; + count++; + } while (--n != 0); + } + return count; +}