From patchwork Sat Aug 9 03:51:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 35178 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D772B21457 for ; Sat, 9 Aug 2014 03:51:46 +0000 (UTC) Received: by mail-oi0-f70.google.com with SMTP id u20sf23094262oif.5 for ; Fri, 08 Aug 2014 20:51:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:sender:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results; bh=TDj6zvMcY291Cx7hGcscq9s5dB2H94GLyfrMLblA0FM=; b=mbFQBBXe0HpPeUcGSm3sHLXbuZjhxCN6dBqXWDnEJGLExtc2yXyQjs1oBt/QsWc4cN dY9lYyACzkb0G7JvPyuF31ICv4ODSSx+Auc6V25dUffvPDmfofv0wwNXe84wPSTiv8NS H9eep0iCxr25rfC57Zq52PNZi1YRWGdqsFiuIJdCxsZmNG7AnmovK/7LzN8/+aF9k5Cp RATCaXMt6gy21bC2DHoUp2OWriJMxp8xI1bHcRvcFdQVVg+yota8DaeEmuG6/16ywcWJ 5u8Pqqww/vPYcOlBDoKXrszAwbVGCguLtxEfbzPu92LQCAJuwCMGhaA6xBNWFIpEJjNZ 7i3w== X-Gm-Message-State: ALoCoQlEyDXujzziqiGzwSrrETrbWVj98nGYd7nFm2zKJbRyq6CEMSTH+RVNvQi4jhWnatUY2K91 X-Received: by 10.182.66.234 with SMTP id i10mr15075684obt.12.1407556306435; Fri, 08 Aug 2014 20:51:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.25.148 with SMTP id 20ls782228qgt.86.gmail; Fri, 08 Aug 2014 20:51:46 -0700 (PDT) X-Received: by 10.52.27.16 with SMTP id p16mr9622351vdg.14.1407556306341; Fri, 08 Aug 2014 20:51:46 -0700 (PDT) Received: from mail-vc0-x22a.google.com (mail-vc0-x22a.google.com [2607:f8b0:400c:c03::22a]) by mx.google.com with ESMTPS id th5si3527979vdb.39.2014.08.08.20.51.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 20:51:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::22a as permitted sender) client-ip=2607:f8b0:400c:c03::22a; Received: by mail-vc0-f170.google.com with SMTP id lf12so9481525vcb.1 for ; Fri, 08 Aug 2014 20:51:46 -0700 (PDT) X-Received: by 10.52.142.102 with SMTP id rv6mr9607323vdb.26.1407556306177; Fri, 08 Aug 2014 20:51:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp4001vcb; Fri, 8 Aug 2014 20:51:45 -0700 (PDT) X-Received: by 10.68.229.166 with SMTP id sr6mr12372050pbc.33.1407556305257; Fri, 08 Aug 2014 20:51:45 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id yc7si7515716pab.174.2014.08.08.20.51.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Aug 2014 20:51:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-374724-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 12392 invoked by alias); 9 Aug 2014 03:51:20 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 12357 invoked by uid 89); 9 Aug 2014 03:51:16 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-ie0-f173.google.com Received: from mail-ie0-f173.google.com (HELO mail-ie0-f173.google.com) (209.85.223.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 09 Aug 2014 03:51:14 +0000 Received: by mail-ie0-f173.google.com with SMTP id tr6so7411808ieb.18 for ; Fri, 08 Aug 2014 20:51:12 -0700 (PDT) X-Received: by 10.50.122.99 with SMTP id lr3mr10719844igb.10.1407556272603; Fri, 08 Aug 2014 20:51:12 -0700 (PDT) Received: from localhost.localdomain (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id w10sm17031666igr.18.2014.08.08.20.51.11 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 08 Aug 2014 20:51:11 -0700 (PDT) Received: from localhost.localdomain (apinskidesktop [127.0.0.1]) by localhost.localdomain (8.14.3/8.14.3/Debian-9.4) with ESMTP id s793pA7L012382 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Fri, 8 Aug 2014 20:51:10 -0700 Received: (from apinski@localhost) by localhost.localdomain (8.14.3/8.14.3/Submit) id s793pAe1012381; Fri, 8 Aug 2014 20:51:10 -0700 From: Andrew Pinski To: gcc-patches@gcc.gnu.org Cc: Andrew Pinski Subject: [PATCH 2/2] Fix ILP32 ld.so. Date: Fri, 8 Aug 2014 20:51:06 -0700 Message-Id: <1407556266-12337-3-git-send-email-apinski@cavium.com> In-Reply-To: <1407556266-12337-1-git-send-email-apinski@cavium.com> References: <1407556266-12337-1-git-send-email-apinski@cavium.com> X-Original-Sender: apinski@cavium.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::22a as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 This patch fixes the original problem that HJL was having with x32 in PR 47727, it is more constraint than HJL's patch only care about what is happening inside a CONST; if we allow it for other cases, the RTL and generated code is incorrect as it does not have the needed zero extend. This allows ILP32 to work correctlya and allows &a + 2 to be still generated correctly when doing a convert_memory_address_addr_space. OK? Bootstrapped and tested on x86_64-linux-gnu (though not with x32 but visually looked at the failing testcase with a much older compiler). Also tested on aarch64-linux-gnu with no regressions and also fixing ld.so for ILP32. Thanks, Andrew Pinski ChangeLog: * explow.c (convert_memory_address_addr_space): Rename to ... (convert_memory_address_addr_space_1): This. Add in_const argument. Inside a CONST RTL, permute the conversion and addition of constant for zero and sign extended pointers. (convert_memory_address_addr_space): New function. --- gcc/explow.c | 40 ++++++++++++++++++++++++++++------------ 1 files changed, 28 insertions(+), 12 deletions(-) diff --git a/gcc/explow.c b/gcc/explow.c index eb7dc85..64017a0 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -310,11 +310,13 @@ break_out_memory_refs (rtx x) an address in the address space's address mode, or vice versa (TO_MODE says which way). We take advantage of the fact that pointers are not allowed to overflow by commuting arithmetic operations over conversions so that address - arithmetic insns can be used. */ + arithmetic insns can be used. IN_CONST is true if this conversion is inside + a CONST. */ -rtx -convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED, - rtx x, addr_space_t as ATTRIBUTE_UNUSED) +static rtx +convert_memory_address_addr_space_1 (enum machine_mode to_mode ATTRIBUTE_UNUSED, + rtx x, addr_space_t as ATTRIBUTE_UNUSED, + bool in_const) { #ifndef POINTERS_EXTEND_UNSIGNED gcc_assert (GET_MODE (x) == to_mode || GET_MODE (x) == VOIDmode); @@ -370,8 +372,8 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED, case CONST: return gen_rtx_CONST (to_mode, - convert_memory_address_addr_space - (to_mode, XEXP (x, 0), as)); + convert_memory_address_addr_space_1 + (to_mode, XEXP (x, 0), as, true)); break; case PLUS: @@ -381,16 +383,18 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED, does not change it or if one operand is a constant and we are using a ptr_extend instruction (POINTERS_EXTEND_UNSIGNED < 0). We can always safely permute them if we are making the address - narrower. */ + narrower. Inside a CONST RTL, this is safe for both pointers + zero or sign extended as pointers cannot wrap. */ if (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (from_mode) || (GET_CODE (x) == PLUS && CONST_INT_P (XEXP (x, 1)) - && (XEXP (x, 1) == convert_memory_address_addr_space - (to_mode, XEXP (x, 1), as) - || POINTERS_EXTEND_UNSIGNED < 0))) + && ((in_const && POINTERS_EXTEND_UNSIGNED !=0) + || XEXP (x, 1) == convert_memory_address_addr_space_1 + (to_mode, XEXP (x, 1), as, in_const) + || POINTERS_EXTEND_UNSIGNED < 0))) return gen_rtx_fmt_ee (GET_CODE (x), to_mode, - convert_memory_address_addr_space - (to_mode, XEXP (x, 0), as), + convert_memory_address_addr_space_1 + (to_mode, XEXP (x, 0), as, in_const), XEXP (x, 1)); break; @@ -402,6 +406,18 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED, x, POINTERS_EXTEND_UNSIGNED); #endif /* defined(POINTERS_EXTEND_UNSIGNED) */ } + +/* Given X, a memory address in address space AS' pointer mode, convert it to + an address in the address space's address mode, or vice versa (TO_MODE says + which way). We take advantage of the fact that pointers are not allowed to + overflow by commuting arithmetic operations over conversions so that address + arithmetic insns can be used. */ + +rtx +convert_memory_address_addr_space (enum machine_mode to_mode, rtx x, addr_space_t as) +{ + return convert_memory_address_addr_space_1 (to_mode, x, as, false); +} /* Return something equivalent to X but valid as a memory address for something of mode MODE in the named address space AS. When X is not itself valid,