From patchwork Thu Feb 11 09:45:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 581786 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 B847414031B for ; Thu, 11 Feb 2016 20:45:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=d4ZpbiCP; 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=IB2Hffe1LZb+9PWNagZlJeavPzCwRXtg6OhwPy1LCoBe+SmnzYS7d Gh8a2qwjgOnsZQRgCM+YmNIXcFIEUMa3kh6Zimg3sZZYADEvzoua6AANRPAEnUHS C2/j79g1rExsCo+r4cY4fZfNhLYAqJgQ3yeSdechhXyGtFDUwzMFmo= 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:subject:message-id:mime-version:content-type; s= default; bh=z6/QHUY+4KzJukx2GGbRgDlBbdA=; b=d4ZpbiCPvHMki2bk1VVE AlIWC7/Ue1x1LYp6M+WzagswVKdG05kTTEJmOywL7vNRfR5qher07YTdvLp9mLT8 opgFH9ciYhrrZnfUZxxXDcEfc742jSDqrAFFQk8fACvWjx+8mwliTv+l3x9gIMFQ u03oA+uNS9GOJoChQAMlVwo= Received: (qmail 49722 invoked by alias); 11 Feb 2016 09:45:49 -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 49712 invoked by uid 89); 11 Feb 2016 09:45:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=Nor, pushes X-HELO: mail-pf0-f174.google.com Received: from mail-pf0-f174.google.com (HELO mail-pf0-f174.google.com) (209.85.192.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 11 Feb 2016 09:45:47 +0000 Received: by mail-pf0-f174.google.com with SMTP id e127so26934452pfe.3 for ; Thu, 11 Feb 2016 01:45:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=nTo/Q/RULCKPV9RZJ1gWBOZRzMhu+m1VcCgXaYcSyDs=; b=KUjSdh4uh0yWEMJxF3MrunJLQPFRH1bA4SZNi1L0h+sb5ZZwnKoMva7e9W8zzaEXyf JC7NeLgdvhHrPZcqsrntqo4r3kpflbkfn9UJfmGjeNhHrgyog000bkoM1v16x12+aDbO /qjgZVREUTCD96RtqMPRhuuyMVRSjMJ09pGEF47j9nL2dfhckGk2K7wu/8JPElfyRduD r6kWscyaXelMha466cSisRW2W2LQYraAUY1dVLgTcV6HMfRJuAVV+x7Tv6DKOwvZEbm5 xr+yukgqbQY4+pjr6eGc2K+CZUb+Pd0TQx1+y2prWhKajD8W2wTGwi5Nj+O+rcic7UYB cIgw== X-Gm-Message-State: AG10YOT+XipS1DfUlpIoNvDPz9Wga5K+IyieL9dtoZEns9EFfxKCzlbnvZq5+bCGiZwL7w== X-Received: by 10.98.0.194 with SMTP id 185mr27684473pfa.139.1455183946246; Thu, 11 Feb 2016 01:45:46 -0800 (PST) Received: from bubble.grove.modra.org (CPE-58-160-146-233.sa.bigpond.net.au. [58.160.146.233]) by smtp.gmail.com with ESMTPSA id p9sm10936387pfa.11.2016.02.11.01.45.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Feb 2016 01:45:45 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id C6B2BEA0157; Thu, 11 Feb 2016 20:15:40 +1030 (ACDT) Date: Thu, 11 Feb 2016 20:15:40 +1030 From: Alan Modra To: gcc-patches@gcc.gnu.org Subject: [PATCH, reload] PRE_INC with invalid hard reg Message-ID: <20160211094540.GB10888@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This is PR68973 part 1, the fix for the regression of g++.dg/pr67211.C on powerpc64-linux -mcpu=power7, which turns out to be a reload problem. Due to uses elsewhere in vsx instructions, reload chooses to put psuedo 185 in fr31, which can't be used as a base register in the following: (set (reg/f:DI 178) (mem/f:DI (pre_inc:DI (reg/f:DI 185)))) So find_reloads_address decides that the (pre_inc:DI (reg:DI 63)) needs reloading, and pushes a reload on the entire address expression. This is unfortunate because the rs6000 backend reload hooks don't look inside a pre_inc and thus don't arrange a secondary reload. Nor does the generic SECONDARY_MEMORY_NEEDED handling, which is only prepared to handle regs or subregs. So reload doesn't allocate the stack temp needed to copy between fprs and gprs on power7. Now it turns out that if find_reloads_address instead pushed a reload of just the (reg:DI 63), then SECONDARY_MEMORY_NEEDED would get a chance to do something. Furthermore, there is existing code in find_reloads_address to do just that for pre_inc, but only enabled for psuedos that don't get a hard reg. The following patch extends this to invalid hard regs. I could have implemented a fix in the rs6000 backend, but it seems likely that other targets may run into this problem. Bootstrapped and regression tested powerpc64le-linux and x86_64-linux. OK to apply? PR target/68973 * reloads.c (find_reloads_address_1): For pre/post-inc/dec with an invalid hard reg, reload just the reg not the entire pre/post-inc/dec address expression. diff --git a/gcc/reload.c b/gcc/reload.c index 6196e63..06426d9 100644 --- a/gcc/reload.c +++ b/gcc/reload.c @@ -5834,14 +5834,16 @@ find_reloads_address_1 (machine_mode mode, addr_space_t as, ? XEXP (x, 0) : reg_equiv_mem (regno)); enum insn_code icode = optab_handler (add_optab, GET_MODE (x)); - if (insn && NONJUMP_INSN_P (insn) && equiv - && memory_operand (equiv, GET_MODE (equiv)) + if (insn && NONJUMP_INSN_P (insn) #if HAVE_cc0 && ! sets_cc0_p (PATTERN (insn)) #endif - && ! (icode != CODE_FOR_nothing - && insn_operand_matches (icode, 0, equiv) - && insn_operand_matches (icode, 1, equiv)) + && (regno < FIRST_PSEUDO_REGISTER + || (equiv + && memory_operand (equiv, GET_MODE (equiv)) + && ! (icode != CODE_FOR_nothing + && insn_operand_matches (icode, 0, equiv) + && insn_operand_matches (icode, 1, equiv)))) /* Using RELOAD_OTHER means we emit this and the reload we made earlier in the wrong order. */ && !reloaded_inner_of_autoinc)