From patchwork Tue Jul 19 09:16:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 105423 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 E8329B6F98 for ; Tue, 19 Jul 2011 19:16:47 +1000 (EST) Received: (qmail 11575 invoked by alias); 19 Jul 2011 09:16:45 -0000 Received: (qmail 11565 invoked by uid 22791); 19 Jul 2011 09:16:44 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-pv0-f175.google.com (HELO mail-pv0-f175.google.com) (74.125.83.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 19 Jul 2011 09:16:29 +0000 Received: by pvf24 with SMTP id 24so4054016pvf.20 for ; Tue, 19 Jul 2011 02:16:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.117.1 with SMTP id p1mr3592357wfc.420.1311066988364; Tue, 19 Jul 2011 02:16:28 -0700 (PDT) Received: by 10.142.89.19 with HTTP; Tue, 19 Jul 2011 02:16:28 -0700 (PDT) In-Reply-To: References: <20110718183936.GA25734@intel.com> Date: Tue, 19 Jul 2011 11:16:28 +0200 Message-ID: Subject: Re: PATCH [6/n] X32: Supprot 32bit address From: Uros Bizjak To: Richard Guenther Cc: "H.J. Lu" , 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 10:46 AM, Richard Guenther wrote: >>>>>>>> TARGET_MEM_REF only works on ptr_mode.   This patch allows 32bit address >>>>>>>> in x32 mode.  OK for trunk? >>>>>>> >>>>>>> Do you perhaps have a testcase to help in analyzing the problem? >>>>>>> >>>>>> >>>>>> See: >>>>>> >>>>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49780 >>>>> >>>>> I don't think that tree-ssa-address/addr_for_mem_ref is correct when >>>>> REALLY_EXPAND is false. It constructs RTX "template" in pointer_mode, >>>>> which is not necessary valid and is rejected from >>>>> ix86_validate_address_p. When really expanding the expression, we have >>>>> a conversion at the end: >>>>> >>>>>  gen_addr_rtx (pointer_mode, sym, bse, idx, st, off, &address, NULL, NULL); >>>>>  if (pointer_mode != address_mode) >>>>>    address = convert_memory_address (address_mode, address); >>>>>  return address; >>>>> >>>>> This is in fact your r175912 change in the fix for PR47383 - you need >>>>> to do something with template as well... >>>>> >>>> >>>> Since TARGET_MEM_REF only works on ptr_mode, I don't think >>>> we can change template.  We just need to accept TARGET_MEM_REF >>>> in ptr_mode and fix it up later. >>> >>> No, a template is used to get some insight into the supported address >>> structure. If there is a mismatch, this approach fails, we can as well >>> give the compiler whatever fake template we want. I have investigated other Pmode != ptr_mode targets, and none of them check the mode of a register in TARGET_LEGITIMATE_ADDRESS_P (or equivalent GO_IF_LEGITIMATE_ADDRESS). All it matters is only if there is a register and regno of the register. Attached patch simply removes these two checks, as it seems they are not needed. This also follows how other Pmode != ptr_mode targets. 2011-07-19 Uros Bizjak PR target/49780 * config/i386/i386.c (ix86_legitimate_address_p): Remove checks that base and index registers are in Pmode. Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32}. Can you please re-test it on x32? BTW: I still think that template should return the same address structure as expansion, but this won't crash the compiler anymore. Uros. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 176433) +++ config/i386/i386.c (working copy) @@ -11653,10 +11653,6 @@ ix86_legitimate_address_p (enum machine_ /* Base is not a register. */ return false; - if (GET_MODE (base) != Pmode) - /* Base is not in Pmode. */ - return false; - if ((strict && ! REG_OK_FOR_BASE_STRICT_P (reg)) || (! strict && ! REG_OK_FOR_BASE_NONSTRICT_P (reg))) /* Base is not valid. */ @@ -11682,10 +11678,6 @@ ix86_legitimate_address_p (enum machine_ /* Index is not a register. */ return false; - if (GET_MODE (index) != Pmode) - /* Index is not in Pmode. */ - return false; - if ((strict && ! REG_OK_FOR_INDEX_STRICT_P (reg)) || (! strict && ! REG_OK_FOR_INDEX_NONSTRICT_P (reg))) /* Index is not valid. */