From patchwork Thu Jul 28 07:33:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Senthil Kumar Selvaraj X-Patchwork-Id: 653619 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 3s0Nsl6VZQz9t1b for ; Thu, 28 Jul 2016 17:34:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Jn2MQm3g; 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:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=V1BpENFpwrBqlOscusetqJTxDkhiVxPkNhi8wm7s7aEXVn3h7vqbN +pwqMgWhsvEWXUde9/yXpNR0bNP/OXzqcCN2A7eEcRLlaJ+1UfCx1hpdtJJbOVt0 UXeM6krwgu8mHi/qrGFzz65b4ziuHmbg14W2dZNZE0gaxaYqqP8Qt0= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=f/i3mF3ErlfYVZ1dtU8FLp/u7fs=; b=Jn2MQm3gf88KEjp0I0/G DgZs4t0kXNRssMlg/t5NZWZQZ8TJ6PypoSblvj1rWa15pQ4KRx8pNjNnl/m+zTXJ 8KxpmV9KLc95mWTKX3Zd5o32hN6V6UPDABji2Z/nEj61kPGOp8YHm/nvbvTndnhq OJMZyGuG5oedOrqvNoTaKCg= Received: (qmail 121657 invoked by alias); 28 Jul 2016 07:34:25 -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 121641 invoked by uid 89); 28 Jul 2016 07:34:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=BAYES_50, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=PLUS, REG_P, reg_p, SUBREG_BYTE X-HELO: eusmtp01.atmel.com Received: from eusmtp01.atmel.com (HELO eusmtp01.atmel.com) (212.144.249.242) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 28 Jul 2016 07:34:23 +0000 Received: from HNOCHT01.corp.atmel.com (10.161.30.161) by eusmtp01.atmel.com (10.161.101.30) with Microsoft SMTP Server (TLS) id 14.3.235.1; Thu, 28 Jul 2016 09:34:15 +0200 Received: from jaguar.atmel.com (10.161.30.18) by HNOCHT01.corp.atmel.com (10.161.30.161) with Microsoft SMTP Server (TLS) id 14.3.235.1; Thu, 28 Jul 2016 09:34:18 +0200 User-agent: mu4e 0.9.17; emacs 24.5.1 From: Senthil Kumar Selvaraj To: "gcc-patches@gcc.gnu.org" , Bernd Schmidt Subject: [Patch, tentative, reload] Make push_reload work with more types of subregs? Date: Thu, 28 Jul 2016 13:03:46 +0530 Message-ID: <8760rqi5d1.fsf@atmel.com> MIME-Version: 1.0 X-IsSubscribed: yes Hi, When analyzing PR 71873 (ICE in push_reload), I found that that code in push_reload that recursively calls push_reload for subreg expressions doesn't correctly set subreg_in_class for a few cases. Specifically, reload_inner_reg_of_subreg returns true if SUBREG_REG(x) is CONSTANT_P or if it's code is PLUS. The code that tries to find a valid class (before recursively calling push_reload), however, only does that if SUBREG_REG is REG_P or if it's a SYMBOL_REF. For the other cases, subreg_in_class is set to the default NO_REGS, and this triggers the rclass != NO_REGS assert just before find_reusable_reload. For PR 71873, reload sees (set (reg/f:HI 87) (const:HI (plus:HI (symbol_ref:HI ("a") ) (const_int 1 [0x1])))) ../test.c:24 83 {*movhi} (expr_list:REG_EQUIV (const:HI (plus:HI (symbol_ref:HI ("a") ) (const_int 1 [0x1]))) and (set (mem:QI (post_dec:HI (reg/f:HI 32 __SP_L__)) [0 S1 A8]) (subreg:QI (reg/f:HI 87) 1)) and decides to replace pseudo reg 87 in the latter insn with the REG_EQUIV it found in the former. The resulting RTL expression (subreg:QI (const:HI (plus:HI (symbol_ref:HI ("a") ) (const_int 1 [0x1]))) 1) does not match any of the conditions that handle subregs because subreg_low_part is false and the inner expr is not a REG or a SYMBOL_REF. Is there a reason why only REG and SYMBOL_REFs get valid subreg_in_class? I tried extending it handle constants and PLUS expressions, and it fixes PR 71873. It also fixes a another bug that was a work around for the reload failure (PR 64452) - that had a plus expression instead of the const. Reg testing on avr and x86_64 did not show any new failures. Is this the right way to fix this? Regards Senthil diff --git gcc/reload.c gcc/reload.c index 06426d9..f80d849 100644 --- gcc/reload.c +++ gcc/reload.c @@ -1141,7 +1141,9 @@ push_reload (rtx in, rtx out, rtx *inloc, rtx *outloc, SUBREG_BYTE (in), GET_MODE (in)), REGNO (SUBREG_REG (in))); - else if (GET_CODE (SUBREG_REG (in)) == SYMBOL_REF) + else if (GET_CODE (SUBREG_REG (in)) == SYMBOL_REF + || CONSTANT_P (SUBREG_REG (in)) + || GET_CODE (SUBREG_REG (in)) == PLUS) subreg_in_class = find_valid_class_1 (inmode, GET_MODE (SUBREG_REG (in)), rclass);