From patchwork Wed Jul 31 16:48:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitar Dimitrov X-Patchwork-Id: 1967203 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=dinux.eu header.i=@dinux.eu header.a=rsa-sha256 header.s=default header.b=MIuyD6IN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WYyjg2JsBz1ybX for ; Thu, 1 Aug 2024 02:49:11 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7F74A385DDC8 for ; Wed, 31 Jul 2024 16:49:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from server28.superhosting.bg (server28.superhosting.bg [217.174.156.11]) by sourceware.org (Postfix) with ESMTPS id D50AB385C6CC for ; Wed, 31 Jul 2024 16:48:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D50AB385C6CC Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dinux.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dinux.eu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D50AB385C6CC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.174.156.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722444527; cv=none; b=gCSJxbSQp8vCy7/IhhRGCuETCDnpZ8xTq8wEWdkV0OmBHfNsq3XbQE/Joca0h6Z6hCw9bK4/pbIOuKIdfBy2hj7iKWEiRyrDQSq5HYO58NbHGwUeWovQS8MWZy0y3+KPIwkBE2tm++lyMLRvuIF9XhqRhmrKVpS3muX1i+8MltA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722444527; c=relaxed/simple; bh=F+4NM1kaHCB+EJhXjYTagWy2SqXlZogF6T8AexaNpoU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=k/jMzWEjDZArSoIRfnAG55rG4xom425yFJIMZ9PPmdsseZdQdgTNoDnFEVLj+GIKUE4k2dezmw5l93ru+EfRqvj0PwbFPbuB7r88YxC3kKM0cWCX4YB//SwtKqBCS6fKAGz7HngjSi9QRXlsym96MQqwaf4ZVyNHJi0wiSgLXjM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dinux.eu; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=py7ME5DNqDvK7HQft0AB/2pA1ttm+y4K27ncBarWado=; b=MIuyD6INRWbRkK4076Vy3rs/Ps tL6fnfBey2wlEDfAJksDfJ9KIMZcFImz2+4rmVRU0KyWs9xsZuzu9Dtrk6JXScYoi44ob6zCYH6Bs 0vzgdJRd4VRmzfYXKNb7YlfcJzK1mJdRj+zLrSy66LbB9BYw6eMyfT1dloWChW2RQcDWlk7Q1kFcC 0swH8VSSAr48TYgmZq1E/ANJVbxhrKM8DLyAq4bfba5++88Kvd+medNjTOTH45nUkArqtiaeC2aeL nBhf76dux2CyU491SFT1DZZKvJSuN11pgLJgXJHKdZcQ3Lvl0bPU3A6wCp+HUqj6WeuB4iMmNWVGZ xd9KsRZA==; Received: from 95-42-20-142.ip.btc-net.bg ([95.42.20.142]:48746 helo=kendros.lan) by server28.superhosting.bg with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1sZCVG-000Agc-2F; Wed, 31 Jul 2024 19:48:44 +0300 From: Dimitar Dimitrov To: gcc-patches@gcc.gnu.org Cc: Dimitar Dimitrov Subject: [committed] pru: Enable section anchoring by default Date: Wed, 31 Jul 2024 19:48:36 +0300 Message-ID: <20240731164836.426789-1-dimitar@dinux.eu> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server28.superhosting.bg X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dinux.eu X-Get-Message-Sender-Via: server28.superhosting.bg: authenticated_id: dimitar@dinux.eu X-Authenticated-Sender: server28.superhosting.bg: dimitar@dinux.eu X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP 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~incoming=patchwork.ozlabs.org@gcc.gnu.org Loading an arbitrary constant address in a register is expensive for PRU. So enable section anchoring by default to utilize the unsigned byte constant offset operand of load/store instructions. gcc/ChangeLog: * common/config/pru/pru-common.cc (TARGET_OPTION_OPTIMIZATION_TABLE): New definition. * config/pru/pru.cc (TARGET_MIN_ANCHOR_OFFSET): Set minimal anchor offset. (TARGET_MAX_ANCHOR_OFFSET): Set maximum anchor offset. gcc/testsuite/ChangeLog: * gcc.target/pru/section-anchors-1.c: New test. * gcc.target/pru/section-anchors-2.c: New test. Signed-off-by: Dimitar Dimitrov --- gcc/common/config/pru/pru-common.cc | 12 ++++++++++++ gcc/config/pru/pru.cc | 6 ++++++ gcc/testsuite/gcc.target/pru/section-anchors-1.c | 14 ++++++++++++++ gcc/testsuite/gcc.target/pru/section-anchors-2.c | 14 ++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 gcc/testsuite/gcc.target/pru/section-anchors-1.c create mode 100644 gcc/testsuite/gcc.target/pru/section-anchors-2.c diff --git a/gcc/common/config/pru/pru-common.cc b/gcc/common/config/pru/pru-common.cc index e8dbf28b2d2..cdc31783dfd 100644 --- a/gcc/common/config/pru/pru-common.cc +++ b/gcc/common/config/pru/pru-common.cc @@ -33,4 +33,16 @@ along with GCC; see the file COPYING3. If not see #undef TARGET_EXCEPT_UNWIND_INFO #define TARGET_EXCEPT_UNWIND_INFO sjlj_except_unwind_info +#undef TARGET_OPTION_OPTIMIZATION_TABLE +#define TARGET_OPTION_OPTIMIZATION_TABLE pru_option_optimization_table + +/* Set default optimization options. */ +static const struct default_options pru_option_optimization_table[] = + { + /* Enable section anchors by default at -O1 or higher. */ + { OPT_LEVELS_1_PLUS, OPT_fsection_anchors, NULL, 1 }, + + { OPT_LEVELS_NONE, 0, NULL, 0 } + }; + struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER; diff --git a/gcc/config/pru/pru.cc b/gcc/config/pru/pru.cc index 491f66432b3..d0700079187 100644 --- a/gcc/config/pru/pru.cc +++ b/gcc/config/pru/pru.cc @@ -3249,6 +3249,12 @@ pru_unwind_word_mode (void) #undef TARGET_PRINT_OPERAND_ADDRESS #define TARGET_PRINT_OPERAND_ADDRESS pru_print_operand_address +#undef TARGET_MIN_ANCHOR_OFFSET +#define TARGET_MIN_ANCHOR_OFFSET 0 + +#undef TARGET_MAX_ANCHOR_OFFSET +#define TARGET_MAX_ANCHOR_OFFSET 255 + #undef TARGET_OPTION_OVERRIDE #define TARGET_OPTION_OVERRIDE pru_option_override diff --git a/gcc/testsuite/gcc.target/pru/section-anchors-1.c b/gcc/testsuite/gcc.target/pru/section-anchors-1.c new file mode 100644 index 00000000000..4c8da5136c3 --- /dev/null +++ b/gcc/testsuite/gcc.target/pru/section-anchors-1.c @@ -0,0 +1,14 @@ +/* Ensure section anchors are enabled by default. */ + +/* { dg-do assemble } */ +/* { dg-options "-O1" } */ +/* { dg-final { object-size text == 24 } } */ + +int aa; +int bb; + +int +test (void) +{ + return aa + bb; +} diff --git a/gcc/testsuite/gcc.target/pru/section-anchors-2.c b/gcc/testsuite/gcc.target/pru/section-anchors-2.c new file mode 100644 index 00000000000..bd5467edad9 --- /dev/null +++ b/gcc/testsuite/gcc.target/pru/section-anchors-2.c @@ -0,0 +1,14 @@ +/* Ensure section anchors are enabled by default. */ + +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +int aa; +int bb; + +int +test (void) +{ + return aa + bb; + /* { dg-final { scan-assembler {\n\tldi32\tr\d+, \.LANCHOR\d+} } } */ +}