From patchwork Tue Jul 19 19:08:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 105508 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 154A2B6F6F for ; Wed, 20 Jul 2011 05:09:07 +1000 (EST) Received: (qmail 9335 invoked by alias); 19 Jul 2011 19:09:05 -0000 Received: (qmail 9325 invoked by uid 22791); 19 Jul 2011 19:09:03 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-pz0-f44.google.com (HELO mail-pz0-f44.google.com) (209.85.210.44) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 19 Jul 2011 19:08:46 +0000 Received: by pzk5 with SMTP id 5so6863936pzk.17 for ; Tue, 19 Jul 2011 12:08:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.80.3 with SMTP id d3mr671612wfb.363.1311102525937; Tue, 19 Jul 2011 12:08:45 -0700 (PDT) Received: by 10.142.89.19 with HTTP; Tue, 19 Jul 2011 12:08:45 -0700 (PDT) In-Reply-To: <20110719163037.GE2687@tyan-ft48-01.lab.bos.redhat.com> References: <20110719163037.GE2687@tyan-ft48-01.lab.bos.redhat.com> Date: Tue, 19 Jul 2011 21:08:45 +0200 Message-ID: Subject: Re: PATCH [6/n] X32: Supprot 32bit address From: Uros Bizjak To: Jakub Jelinek Cc: "H.J. Lu" , Richard Guenther , gcc-patches@gcc.gnu.org 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 On Tue, Jul 19, 2011 at 6:30 PM, Jakub Jelinek wrote: >> Sometimes, the compiler is really creative in inventing instructions: >> >> (insn 47 46 49 7 (set (reg:SI 68 [ D.1686 ]) >>         (subreg:SI (plus:SF (reg:SF 159 [ D.1685 ]) >>                 (reg:SF 159 [ D.1685 ])) 0)) omp_atomic1.f90:17 247 {*lea_2} >>      (expr_list:REG_DEAD (reg:SF 159 [ D.1685 ]) >>         (nil))) >> >> Really funny. > > That's the job of combiner to try all kinds of stuff and it is the > responsibility of the backend to reject those.  I think it would be better > to get back to testing Pmode in the legitimate address hook, perhaps > allowing ptr_mode too in addition to Pmode (which for -m32/-m64 won't mean > any change, just for -mx32). I agree that we still need to check naked registers. However, for 64bit targets it is OK to pass both, SImode and DImode registers. We are sure that SImode values in DImode regs have top 32bits equal to 0 in address calculations. This is not true for QImode regs (assignment to lowpart only). We also have to prevent non-integer registers. Attached is my final version of the patch. Uros. Index: predicates.md =================================================================== --- predicates.md (revision 176462) +++ predicates.md (working copy) @@ -796,7 +796,7 @@ ;; Return true if op if a valid address, and does not contain ;; a segment override. -(define_special_predicate "no_seg_address_operand" +(define_predicate "no_seg_address_operand" (match_operand 0 "address_operand") { struct ix86_address parts; Index: i386.c =================================================================== --- i386.c (revision 176462) +++ i386.c (working copy) @@ -11085,8 +11085,16 @@ ix86_decompose_address (rtx addr, struct int retval = 1; enum ix86_address_seg seg = SEG_DEFAULT; - if (REG_P (addr) || GET_CODE (addr) == SUBREG) + if (REG_P (addr)) base = addr; + else if (GET_CODE (addr) == SUBREG) + { + /* Allow only subregs of DImode hard regs. */ + if (register_no_elim_operand (SUBREG_REG (addr), DImode)) + base = addr; + else + return 0; + } else if (GET_CODE (addr) == PLUS) { rtx addends[4], op; @@ -11643,8 +11651,7 @@ ix86_legitimate_address_p (enum machine_ /* Base is not a register. */ return false; - if (GET_MODE (base) != Pmode) - /* Base is not in Pmode. */ + if (GET_MODE (base) != SImode && GET_MODE (base) != DImode) return false; if ((strict && ! REG_OK_FOR_BASE_STRICT_P (reg)) @@ -11672,8 +11679,7 @@ ix86_legitimate_address_p (enum machine_ /* Index is not a register. */ return false; - if (GET_MODE (index) != Pmode) - /* Index is not in Pmode. */ + if (GET_MODE (index) != SImode && GET_MODE (index) != DImode) return false; if ((strict && ! REG_OK_FOR_INDEX_STRICT_P (reg))