From patchwork Thu Sep 10 00:57:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 516073 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 DDB5014028F for ; Thu, 10 Sep 2015 10:58:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=DVlazsxR; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=xiX83GoTAdaJwSecU 0jCO7IW2woMO+PMqW67KyrWb1GOnZeUNfLXzWa6qdXBpMbr0eD4w0A8mirkg6YHe mk7PeWCHn1t7ISh+S0PVOZM5c2NLNn2Ddssrj5Gz49VMylbi3U6eL1uk0M6bKATs h7ZDEXQ3TyEJZyC0/29uyxo2Pg= 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=OkgJGnVxVpunn3dCFsfxIRn leuQ=; b=DVlazsxRsFDoqZYWd//cBUEyxuxTaf/okgEXQhmCm0WcaygNaA3BL3Z 2dLpsOrZXMwqwFMdfVEWr5TVJObEwZDkzeqJ7KpxHC/noa2wJvznbw5d5v22L3r8 VtbgocHKJPvMEk6kXZiyLKkWJp95Fm8i7nN7vze0DZ610UjwiPYM= Received: (qmail 117827 invoked by alias); 10 Sep 2015 00:58:06 -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 117810 invoked by uid 89); 10 Sep 2015 00:58:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f44.google.com Received: from mail-pa0-f44.google.com (HELO mail-pa0-f44.google.com) (209.85.220.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 10 Sep 2015 00:58:04 +0000 Received: by pacfv12 with SMTP id fv12so25902977pac.2 for ; Wed, 09 Sep 2015 17:58:02 -0700 (PDT) X-Received: by 10.67.8.106 with SMTP id dj10mr67437914pad.123.1441846682127; Wed, 09 Sep 2015 17:58:02 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-163-67.gqzg1.fli.bigpond.net.au. [58.160.163.67]) by smtp.gmail.com with ESMTPSA id qr5sm8417033pbb.26.2015.09.09.17.58.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 17:58:00 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id B8735EA0076; Thu, 10 Sep 2015 10:27:55 +0930 (ACST) Date: Thu, 10 Sep 2015 10:27:55 +0930 From: Alan Modra To: David Edelsohn , Ulrich Weigand Cc: GCC Patches Subject: Re: [RS6000] Fix PowerPC ICE due to secondary_reload ignoring reload replacements Message-ID: <20150910005755.GA4330@bubble.grove.modra.org> References: <20150908124658.8E0D523EC@oc7340732750.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150908124658.8E0D523EC@oc7340732750.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes On Tue, Sep 08, 2015 at 02:46:58PM +0200, Ulrich Weigand wrote: > David Edelsohn wrote: > > On Mon, Sep 7, 2015 at 11:47 PM, Alan Modra wrote: > > > In https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67378 analysis I show > > > the reason for this PR is that insns emitted by secondary reload > > > patterns are being generated without taking into account other reloads > > > that may have occurred. We run into this problem when an insn has a > > > pseudo that doesn't get a hard reg, and the pseudo is used in a way > > > that requires a secondary reload. In this case the secondary reload > > > is needed due to gcc generating a 64-bit gpr load from memory insn > > > with an address offset not a multiple of 4. > > > > > > PR target/67378 > > > * config/rs6000/rs6000.c (rs6000_secondary_reload_gpr): Find > > > reload replacement for PRE_MODIFY address reg. > > > > I'm okay with this patch, but I'd like Uli to double-check it when he > > has a moment. > > The patch looks OK to me. We definitely need to check for replacements > in secondary reload in such cases. Thanks for reviewing! I think rs6000_secondary_reload_inner needs the same. (https://gcc.gnu.org/ml/gcc-patches/2014-11/msg01114.html removed a bunch of find_replacement calls that I'd added previously.) This patch reinstates some of the calls, a little more elegantly than in my original effort. I've also corrected an obvious error with the PRE_DEC address offset. Bootstrapped and regression tested powerpc64le-linux. OK for mainline and gcc-5? * config/rs6000/rs6000.c (rs6000_secondary_reload_inner): Find reload replacement for PRE_INC/DEC, PRE_MODIFY and AND address regs. Negate offset for PRE_DEC. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index b9f35cd..f616b21 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -18020,7 +18020,12 @@ rs6000_secondary_reload_inner (rtx reg, rtx mem, rtx scratch, bool store_p) if ((addr_mask & RELOAD_REG_PRE_INCDEC) == 0) { - emit_insn (gen_add2_insn (op_reg, GEN_INT (GET_MODE_SIZE (mode)))); + if (!HARD_REGISTER_P (op_reg)) + op_reg = find_replacement (&XEXP (addr, 0)); + int delta = GET_MODE_SIZE (mode); + if (GET_CODE (addr) == PRE_DEC) + delta = -delta; + emit_insn (gen_add2_insn (op_reg, GEN_INT (delta))); new_addr = op_reg; } break; @@ -18035,6 +18040,8 @@ rs6000_secondary_reload_inner (rtx reg, rtx mem, rtx scratch, bool store_p) if ((addr_mask & RELOAD_REG_PRE_MODIFY) == 0) { + if (!HARD_REGISTER_P (op0)) + op0 = find_replacement (&XEXP (addr, 0)); emit_insn (gen_rtx_SET (op0, op1)); new_addr = reg; } @@ -18048,7 +18055,11 @@ rs6000_secondary_reload_inner (rtx reg, rtx mem, rtx scratch, bool store_p) if ((addr_mask & RELOAD_REG_AND_M16) == 0) { if (REG_P (op0) || GET_CODE (op0) == SUBREG) - op_reg = op0; + { + op_reg = op0; + if (!HARD_REGISTER_P (op_reg)) + op_reg = find_replacement (&XEXP (addr, 0)); + } else if (GET_CODE (op1) == PLUS) {