From patchwork Fri Jul 9 09:54:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 58381 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 AFFB2B6F17 for ; Fri, 9 Jul 2010 19:55:24 +1000 (EST) Received: (qmail 14240 invoked by alias); 9 Jul 2010 09:55:22 -0000 Received: (qmail 14229 invoked by uid 22791); 9 Jul 2010 09:55:21 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_OV, TW_QE, TW_VH, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Jul 2010 09:55:16 +0000 Received: (qmail 15891 invoked from network); 9 Jul 2010 09:55:13 -0000 Received: from unknown (HELO ?84.152.202.138?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 9 Jul 2010 09:55:13 -0000 Message-ID: <4C36F1BC.8080401@codesourcery.com> Date: Fri, 09 Jul 2010 11:54:04 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100625 Thunderbird/3.0.5 MIME-Version: 1.0 To: GCC Patches CC: Richard Earnshaw Subject: A problem simplifying subregs of the hard frame pointer 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 While testing some other Thumb-1 changes, I got an abort while generating thumb_movhi_clobber for a secondary reload. The pattern calls gcc_unreachable when it finds a case it can't handle. There's a FIXME there that other cases might need to be handled, but looking closer, the entire pattern seems bogus; it requests two scratch regs (one DImode reg) and doesn't use them. The circumstances in which we arrive there also seemed suspect. We were reloading an insn of the form (set (mem:HI (some address)) (subreg:HI (reg:SI 7))) Reload did _not_ choose the reg->mem alternative of the movhi pattern, which is crazy. The reason it didn't is that reg 7 is the hard frame pointer, and simplify_subreg_regno didn't want to simplify the subreg here (-fomit-frame-pointer was on of course). So, find_reloads set force_reload for the register operand, which seems to have been enough to confuse its cost calculations. Fixed by the first part of this patch; I see no reason to treat the hard frame pointer register specially - it's typically just a general reg. If FRAME_POINTER_REGNUM == HARD_FRAME_POINTER_REGNUM, the test will have the same effect as before, which is probably still wrong, but for now it's a safe change to make. The other part removes the strange-looking part frmo the thumb_movhi_clobber register and restores it to just a call to gcc_unreachable. This is still ugly, but it's essentially the state it was in before http://gcc.gnu.org/ml/gcc-patches/2005-08/msg01210.html which presumably changed this because of the bug I'm fixing here. Regression tested, together with some other patches, on qemu-system-armv7-3/arch=armv7-a/thumb qemu-system-armv7-3/thumb qemu-system-armv7-3 which only showed up one unrelated problem for which I'm testing a fix. Ok (rtlanal and ARM parts)? Bernd * rtlanal.c (simplify_subreg_regno): Don't treat HARD_FRAME_POINTER_REGNUM specially. * config/arm/arm.md (thumb_movhi_clobber): Restore previous version of the pattern that always calls gcc_unreachable. Index: rtlanal.c =================================================================== --- rtlanal.c (revision 161987) +++ rtlanal.c (working copy) @@ -3297,8 +3297,7 @@ simplify_subreg_regno (unsigned int xreg /* We shouldn't simplify stack-related registers. */ if ((!reload_completed || frame_pointer_needed) - && (xregno == FRAME_POINTER_REGNUM - || xregno == HARD_FRAME_POINTER_REGNUM)) + && xregno == FRAME_POINTER_REGNUM) return -1; if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM Index: config/arm/arm.md =================================================================== --- config/arm/arm.md (revision 161987) +++ config/arm/arm.md (working copy) @@ -5666,17 +5666,9 @@ (define_expand "thumb_movhi_clobber" (match_operand:HI 1 "register_operand" "")) (clobber (match_operand:DI 2 "register_operand" ""))] "TARGET_THUMB1" - " - if (strict_memory_address_p (HImode, XEXP (operands[0], 0)) - && REGNO (operands[1]) <= LAST_LO_REGNUM) - { - emit_insn (gen_movhi (operands[0], operands[1])); - DONE; - } - /* XXX Fixme, need to handle other cases here as well. */ +{ gcc_unreachable (); - " -) +}) ;; We use a DImode scratch because we may occasionally need an additional ;; temporary if the address isn't offsettable -- push_reload doesn't seem