From patchwork Fri Oct 21 22:43:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Stump X-Patchwork-Id: 121073 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]) by ozlabs.org (Postfix) with SMTP id 94883B71C4 for ; Sat, 22 Oct 2011 09:43:36 +1100 (EST) Received: (qmail 668 invoked by alias); 21 Oct 2011 22:43:32 -0000 Received: (qmail 654 invoked by uid 22791); 21 Oct 2011 22:43:29 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from qmta13.westchester.pa.mail.comcast.net (HELO qmta13.westchester.pa.mail.comcast.net) (76.96.59.243) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 21 Oct 2011 22:43:15 +0000 Received: from omta04.westchester.pa.mail.comcast.net ([76.96.62.35]) by qmta13.westchester.pa.mail.comcast.net with comcast id nahr1h0010ldTLk5DajFst; Fri, 21 Oct 2011 22:43:15 +0000 Received: from up.mrs.kithrup.com ([24.4.193.8]) by omta04.westchester.pa.mail.comcast.net with comcast id najD1h02T0BKwT43QajEsg; Fri, 21 Oct 2011 22:43:15 +0000 From: Mike Stump Subject: fix typo in reload Date: Fri, 21 Oct 2011 15:43:12 -0700 Message-Id: Cc: Bernd Schmidt To: GCC Patches Mime-Version: 1.0 (Apple Message framework v1084) X-IsSubscribed: yes 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 In: r37370 | bernds | 2000-11-10 09:10:29 -0800 (Fri, 10 Nov 2000) | 2 lines Several fixes to make reload handle POST_MODIFY correctly. We see: -regno_clobbered_p (regno, insn, mode) +regno_clobbered_p (regno, insn, mode, sets) unsigned int regno; rtx insn; enum machine_mode mode; + int sets; { int nregs = HARD_REGNO_NREGS (regno, mode); int endregno = regno + nregs; - if (GET_CODE (PATTERN (insn)) == CLOBBER + if ((GET_CODE (PATTERN (insn)) == CLOBBER + || (sets && GET_CODE (PATTERN (insn)) == SET)) && GET_CODE (XEXP (PATTERN (insn), 0)) == REG) { int test = REGNO (XEXP (PATTERN (insn), 0)); @@ -6578,7 +6592,9 @@ regno_clobbered_p (regno, insn, mode) for (; i >= 0; i--) { rtx elt = XVECEXP (PATTERN (insn), 0, i); - if (GET_CODE (elt) == CLOBBER && GET_CODE (XEXP (elt, 0)) == REG) + if ((GET_CODE (elt) == CLOBBER + || (sets && GET_CODE (PATTERN (insn)) == SET)) + && GET_CODE (XEXP (elt, 0)) == REG) { int test = REGNO (XEXP (elt, 0)); But, if you examine the PARALLEL code carefully, we discover it doesn't use elt, instead it uses PATTERN (INSN) which is wrong. :-( I'd propose: to fix it. It fixes my testcase, and I'm doing a regression run now on a normal machine to further test, but I'm pretty sure it is correct. Ok? I would ask for 2.6, but, apparently no one else hits this (not in 11 years), so, I think it is safe to punt. This is the hairy reload bug I've been chasing. What a PITA to chase down. You don't want to see my testcase. 20 minutes to compile, the nice thing is, it easily catches things like this. The english on this is, if you have an instruction, that needs a input and output reload on an operand, and that is resolved by going to memory, and that memory address is sp+const, and that const is too large for a normal displacement and needs to be reloaded into a register, and the main instruction uses a reload register (I think that's true) as output, but that register is dead, then, we would try and use that dead register for the address reload on the input reloads, and on the address reload on the output reloads, but, this register is also the output of the main instruction, which is a PARALLEL with two sets. Note, that might not be quite enough to trigger. I also have register classes in play and movements between classes that can't do certain things, like move to memory, or move large numbers into. 2011-10-21 Mike Stump * reload.c (regno_clobbered_p): Fix typo. Index: reload.c =================================================================== --- reload.c (revision 180265) +++ reload.c (working copy) @@ -7231,7 +7231,7 @@ regno_clobbered_p (unsigned int regno, r { rtx elt = XVECEXP (PATTERN (insn), 0, i); if ((GET_CODE (elt) == CLOBBER - || (sets == 1 && GET_CODE (PATTERN (insn)) == SET)) + || (sets == 1 && GET_CODE (elt) == SET)) && REG_P (XEXP (elt, 0))) { unsigned int test = REGNO (XEXP (elt, 0)); Index: reload.c =================================================================== --- reload.c (revision 180265) +++ reload.c (working copy) @@ -7231,7 +7231,7 @@ regno_clobbered_p (unsigned int regno, r { rtx elt = XVECEXP (PATTERN (insn), 0, i); if ((GET_CODE (elt) == CLOBBER - || (sets == 1 && GET_CODE (PATTERN (insn)) == SET)) + || (sets == 1 && GET_CODE (elt) == SET)) && REG_P (XEXP (elt, 0))) { unsigned int test = REGNO (XEXP (elt, 0));