From patchwork Thu Nov 16 17:54:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 165908 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6513:b0:164:83eb:24d7 with SMTP id sk19csp32080rwb; Thu, 16 Nov 2023 09:55:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRs3eadjPbFcguIV3l9sWGWptcSNAhK500pT0uvYILBCVonDN3CmwK7vV5hwgI9H9Mx951 X-Received: by 2002:a05:6808:2393:b0:3b6:d108:1ff3 with SMTP id bp19-20020a056808239300b003b6d1081ff3mr20808518oib.2.1700157305387; Thu, 16 Nov 2023 09:55:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700157305; cv=pass; d=google.com; s=arc-20160816; b=Yn7aIbxoLcA5/UMtBqv45W4XqU7gdZuHUqe/CDM1MU4jihViuUr53xfZCGsnqXhKfE tb42ZTH7OFTmoW10WAvQ+Ayq9o/a9UjAhX1G36W+1YanG6CNCTRmPo8jZ/Tb3ZVltDCG 4T5VcvwKwr9L8A0rHqG8JZgBXvTpgd80IOQglsfXKDAkqFcBkGALZPkg0LBkDM4iN8XA sAiXvshCMQVThWqYWRRwuPpO+IwbjRTbiW0l2mv/aAsBZo9QYgH/4CdQntw5FcQtJe5J jjyMXkdkyE+2gmDSnJ4es31ewr6MeqHM7OQVIqkCISBtwxUDL5oCy5S2x9RFx2nxAjmd leOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:message-id:subject:to:from:date:arc-filter :dmarc-filter:delivered-to; bh=+aCMc+Bmy+tTF3yIBlO+DmXIqftZUmaQ6RAc8Lv8084=; fh=1L2/IiukS00vgiXcKREcvt+pFBEM8GuYOng2C1a9k1k=; b=e3U9Fie5tRxhnkazWNu9SQUMVvDpDbYi1TK02kRbZGsodhjIoArXGvuCIXKcUjKQlF rwBWXIs7SEgbw553TaOyowVgDHzXBxBL6aBwZNO0IZpJUTBMaAHCFrJt6cfCtFLXDWwb 2JGEkpEoXW4i4Qw6B2SdFR8W+qlZSTTtdTyt0Bl8N0+j64NKpJYCBytp+vYwG7t+gBI+ 6y+XMfX+IObvXYzFhCDd9fcrQLlcpTee36G65NVjojrb51d0EFTR/2H+Svb689ClVQEC v3DGZR9doA2zTm1/ugqq/cmJrHjco8i/81gLBdRdyVREMWMh0RWw/YfqBSdh7JXEPlIa wo2Q== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o10-20020a05620a2a0a00b0077893a5a7fdsi12830352qkp.740.2023.11.16.09.55.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 09:55:05 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22D61385800C for ; Thu, 16 Nov 2023 17:55:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from dellerweb.de (dellerweb.de [173.249.48.176]) by sourceware.org (Postfix) with ESMTPS id A08C33858D20 for ; Thu, 16 Nov 2023 17:54:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A08C33858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=parisc-linux.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=parisc-linux.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A08C33858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=173.249.48.176 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700157281; cv=none; b=dVi5FJ3WlMyJMxrWCXPRYEA7yQ+ZGar/Y2YB/KAIb2/zYSaXsEBbcpi6SQ8fifSM4yV48t3P/I3XCWAEQhWZnZO+PEjm20JOZ3JJx5OHD4JQFHosGIlZuL7obngd6wuoCSVYul1RToYjoOkg9KBcaANDxx2TONDgcRMy0CPfRaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700157281; c=relaxed/simple; bh=GSGeJdJFt9o6u3mCkhTZ8qUVOJoTqqbb+vFGlWTXlWo=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=bKYRJgMg1ijfgLQxjcpw0qRShQ2tdu0BKTv4u7pXuunaTTpY6iGRA074d3giPJIPIh1OLy9oBqzlPrr+UnYav1bSugbJlHa5BNghkU2SbXuBi7Gb0e8eU2Z/2ytHfx9JIA2zg9hsCQLLgdpv7xUcJ8CxOUQPSg0Q459bLx6moos= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mx3210.localdomain (bras-base-otwaon0906w-grc-03-142-126-114-79.dsl.bell.ca [142.126.114.79]) by dellerweb.de (Postfix) with ESMTPSA id 3853E16001E3; Thu, 16 Nov 2023 18:54:37 +0100 (CET) Received: by mx3210.localdomain (Postfix, from userid 1000) id E954822012C; Thu, 16 Nov 2023 17:54:33 +0000 (UTC) Date: Thu, 16 Nov 2023 17:54:33 +0000 From: John David Anglin To: GCC Patches Subject: [committed] hppa: Revise REG+D address support to allow long displacements before reload Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782744146894226564 X-GMAIL-MSGID: 1782744146894226564 Tested on hppa-unknown-linux-gnu and hppa64-hp-hpux11.11. Committed to trunk. This patch works around problem compiling python3.11 by improving REG+D address handling. The change results in smaller code and reduced register pressure. Dave --- hppa: Revise REG+D address support to allow long displacements before reload In analyzing PR rtl-optimization/112415, I realized that restricting REG+D offsets to 5-bits before reload results in very poor code and complexities in optimizing these instructions after reload. The general problem is long displacements are not allowed for floating point accesses when generating PA 1.1 code. Even with PA 2.0, there is a ELF linker bug that prevents using long displacements for floating point loads and stores. In the past, enabling long displacements before reload caused issues in reload. However, there have been fixes in the handling of reloads for floating-point accesses. This change allows long displacements before reload and corrects a couple of issues in the constraint handling for integer and floating-point accesses. 2023-11-16 John David Anglin gcc/ChangeLog: PR rtl-optimization/112415 * config/pa/pa.cc (pa_legitimate_address_p): Allow 14-bit displacements before reload. Simplify logic flow. Revise comments. * config/pa/pa.h (TARGET_ELF64): New define. (INT14_OK_STRICT): Update define and comment. * config/pa/pa64-linux.h (TARGET_ELF64): Define. * config/pa/predicates.md (base14_operand): Don't check alignment of short displacements. (integer_store_memory_operand): Don't return true when reload_in_progress is true. Remove INT_5_BITS check. (floating_point_store_memory_operand): Don't return true when reload_in_progress is true. Use INT14_OK_STRICT to check whether long displacements are always okay. diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc index 218c48b4ae0..565c948a9e6 100644 --- a/gcc/config/pa/pa.cc +++ b/gcc/config/pa/pa.cc @@ -10819,23 +10819,29 @@ pa_legitimate_address_p (machine_mode mode, rtx x, bool strict, code_helper) if (GET_CODE (index) == CONST_INT) { + /* Short 5-bit displacements always okay. */ if (INT_5_BITS (index)) return true; - /* When INT14_OK_STRICT is false, a secondary reload is needed - to adjust the displacement of SImode and DImode floating point - instructions but this may fail when the register also needs - reloading. So, we return false when STRICT is true. We - also reject long displacements for float mode addresses since - the majority of accesses will use floating point instructions - that don't support 14-bit offsets. */ - if (!INT14_OK_STRICT - && (strict || !(reload_in_progress || reload_completed)) - && mode != QImode - && mode != HImode) + if (!base14_operand (index, mode)) return false; - return base14_operand (index, mode); + /* Long 14-bit displacements always okay for these cases. */ + if (INT14_OK_STRICT + || mode == QImode + || mode == HImode) + return true; + + /* A secondary reload may be needed to adjust the displacement + of floating-point accesses when STRICT is nonzero. */ + if (strict) + return false; + + /* We get significantly better code if we allow long displacements + before reload for all accesses. Instructions must satisfy their + constraints after reload, so we must have an integer access. + Return true for both cases. */ + return true; } if (!TARGET_DISABLE_INDEXING diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index e65af522966..aba2cec7357 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -37,6 +37,11 @@ extern unsigned long total_code_bytes; #define TARGET_ELF32 0 #endif +/* Generate code for ELF64 ABI. */ +#ifndef TARGET_ELF64 +#define TARGET_ELF64 0 +#endif + /* Generate code for SOM 32bit ABI. */ #ifndef TARGET_SOM #define TARGET_SOM 0 @@ -823,12 +828,11 @@ extern int may_call_alloca; /* Nonzero if 14-bit offsets can be used for all loads and stores. This is not possible when generating PA 1.x code as floating point - loads and stores only support 5-bit offsets. Note that we do not - forbid the use of 14-bit offsets for integer modes. Instead, we - use secondary reloads to fix REG+D memory addresses for integer - mode floating-point loads and stores. + accesses only support 5-bit offsets. Note that we do not forbid + the use of 14-bit offsets prior to reload. Instead, we use secondary + reloads to fix REG+D memory addresses for floating-point accesses. - FIXME: the ELF32 linker clobbers the LSB of the FP register number + FIXME: the GNU ELF linker clobbers the LSB of the FP register number in PA 2.0 floating-point insns with long displacements. This is because R_PARISC_DPREL14WR and other relocations like it are not yet supported by GNU ld. For now, we reject long displacements @@ -836,7 +840,7 @@ extern int may_call_alloca; #define INT14_OK_STRICT \ (TARGET_SOFT_FLOAT \ - || (TARGET_PA_20 && !TARGET_ELF32)) + || (TARGET_PA_20 && !TARGET_ELF32 && !TARGET_ELF64)) /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx and check its validity for a certain class. diff --git a/gcc/config/pa/pa64-linux.h b/gcc/config/pa/pa64-linux.h index f61c9e16f44..33fed023643 100644 --- a/gcc/config/pa/pa64-linux.h +++ b/gcc/config/pa/pa64-linux.h @@ -17,6 +17,10 @@ You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see . */ +/* 64-bit ELF target. */ +#undef TARGET_ELF64 +#define TARGET_ELF64 1 + #if 0 /* needs some work :-( */ /* If defined, this macro specifies a table of register pairs used to eliminate unneeded registers that point into the stack frame. */ diff --git a/gcc/config/pa/predicates.md b/gcc/config/pa/predicates.md index 08071b2d279..1b50020e1de 100644 --- a/gcc/config/pa/predicates.md +++ b/gcc/config/pa/predicates.md @@ -267,6 +267,10 @@ if (!INT_14_BITS (op)) return false; + /* Short displacement. */ + if (INT_5_BITS (op)) + return true; + /* Although this may not be necessary, we require that the base value is correctly aligned for its mode as this is assumed in the instruction encoding. */ @@ -304,15 +308,12 @@ if (reg_plus_base_memory_operand (op, mode)) { - if (reload_in_progress) - return true; - /* Extract CONST_INT operand. */ if (GET_CODE (op) == SUBREG) op = SUBREG_REG (op); op = XEXP (op, 0); op = REG_P (XEXP (op, 0)) ? XEXP (op, 1) : XEXP (op, 0); - return base14_operand (op, mode) || INT_5_BITS (op); + return base14_operand (op, mode); } if (!MEM_P (op)) @@ -341,17 +342,12 @@ if (reg_plus_base_memory_operand (op, mode)) { - if (reload_in_progress) - return true; - /* Extract CONST_INT operand. */ if (GET_CODE (op) == SUBREG) op = SUBREG_REG (op); op = XEXP (op, 0); op = REG_P (XEXP (op, 0)) ? XEXP (op, 1) : XEXP (op, 0); - return ((TARGET_PA_20 - && !TARGET_ELF32 - && base14_operand (op, mode)) + return ((INT14_OK_STRICT && base14_operand (op, mode)) || INT_5_BITS (op)); }