From patchwork Tue Apr 2 07:03:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cheng X-Patchwork-Id: 1918658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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 4V7zPw6lcbz1yZ4 for ; Tue, 2 Apr 2024 18:04:04 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 381543858425 for ; Tue, 2 Apr 2024 07:04:03 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 6DD9D3858431 for ; Tue, 2 Apr 2024 07:03:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6DD9D3858431 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6DD9D3858431 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712041419; cv=none; b=ahCcPytCWJfB8YKkMXt1wF4vxLQNQ2451hdmUZ1FsBcJs4QSojVQhKBTWY7yfIB9AGrZV7jEFFlIpzQAdaUgLAX9MQPGOKobisj2f8/eE7mlZpf6J61dJFqJTvnfWGSHkHFFYCqGWY2ms8xrUccPtph3n4GTWHTjfuLs0eb1eWY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712041419; c=relaxed/simple; bh=F+jRmYqdkxFy//0XyxwkRAxaWsRlhjS9lnWuVQT9LpA=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=n2eBUiKm3Ld2AGJXeHZ+osvQxx9Dq04MEWIx82o2f4VMseJMe8/WWW8B9g8EfyuMisn9VXxeaw3wedfQcKUJZDkafHyfw8O0xarCnmL/87mhRhQhWar03sLZDbmMWva6rdhhUelWY1+CqrvpakCHOi0CzjYrLEHmjMPT16wQsIQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8Bx3+u7rQtmFzwiAA--.12989S3; Tue, 02 Apr 2024 15:03:24 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxqhK4rQtmyZZxAA--.12642S2; Tue, 02 Apr 2024 15:03:22 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: mark@klomp.org, xry111@xry111.site, i@xen0n.name, xuchenghua@loongson.cn, Lulu Cheng Subject: [PATCH v1] LoongArch: Set default alignment for functions jumps and loops [PR112919]. Date: Tue, 2 Apr 2024 15:03:19 +0800 Message-Id: <20240402070319.25666-1-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8CxqhK4rQtmyZZxAA--.12642S2 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoWxKF1UXw47AF1DCr17WF13ZFc_yoW7Gw4Dpr y3Zwn8JFW8Ars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-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, 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 Xi Ruoyao set the alignment rules under LA464 in commit r14-1839, but the macro ASM_OUTPUT_ALIGN_WITH_NOP was removed in R14-4674, which affected the alignment rules. So I set different aligns on LA464 and LA664 again to test the performance of spec2006, and modify the alignment based on the test results. gcc/ChangeLog: PR target/112919 * config/loongarch/loongarch-def.cc (la664_align): Newly defined function that sets alignment rules under the LA664 microarchitecture. * config/loongarch/loongarch-opts.cc (loongarch_target_option_override): If not optimizing for size, set the default alignment to what the target wants. * config/loongarch/loongarch-tune.h (struct loongarch_align): Add new member variables jump and loop. --- gcc/config/loongarch/loongarch-def.cc | 11 ++++++++--- gcc/config/loongarch/loongarch-opts.cc | 19 +++++++++++++------ gcc/config/loongarch/loongarch-tune.h | 22 +++++++++++++++------- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/gcc/config/loongarch/loongarch-def.cc b/gcc/config/loongarch/loongarch-def.cc index e8c129ce643..63a8f108f4e 100644 --- a/gcc/config/loongarch/loongarch-def.cc +++ b/gcc/config/loongarch/loongarch-def.cc @@ -81,14 +81,19 @@ array_tune loongarch_cpu_cache = static inline loongarch_align la464_align () { - return loongarch_align ().function_ ("32").label_ ("16"); + return loongarch_align ().function_ ("32").loop_ ("16").jump_ ("16"); +} + +static inline loongarch_align la664_align () +{ + return loongarch_align ().function_ ("8").loop_ ("8").jump_ ("32"); } array_tune loongarch_cpu_align = array_tune () - .set (CPU_LOONGARCH64, la464_align ()) + .set (CPU_LOONGARCH64, la664_align ()) .set (CPU_LA464, la464_align ()) - .set (CPU_LA664, la464_align ()); + .set (CPU_LA664, la664_align ()); /* Default RTX cost initializer. */ loongarch_rtx_cost_data::loongarch_rtx_cost_data () diff --git a/gcc/config/loongarch/loongarch-opts.cc b/gcc/config/loongarch/loongarch-opts.cc index 2a6fc41b247..7b21cc311a8 100644 --- a/gcc/config/loongarch/loongarch-opts.cc +++ b/gcc/config/loongarch/loongarch-opts.cc @@ -922,13 +922,20 @@ loongarch_target_option_override (struct loongarch_target *target, { loongarch_update_gcc_opt_status (target, opts, opts_set); - /* alignments */ - if (opts->x_flag_align_functions && !opts->x_str_align_functions) - opts->x_str_align_functions - = loongarch_cpu_align[target->cpu_tune].function; + /* If not optimizing for size, set the default + alignment to what the target wants. */ + if (!opts->x_optimize_size) + { + if (opts->x_flag_align_functions && !opts->x_str_align_functions) + opts->x_str_align_functions + = loongarch_cpu_align[target->cpu_tune].function; + + if (opts->x_flag_align_loops && !opts->x_str_align_loops) + opts->x_str_align_loops = loongarch_cpu_align[target->cpu_tune].loop; - if (opts->x_flag_align_labels && !opts->x_str_align_labels) - opts->x_str_align_labels = loongarch_cpu_align[target->cpu_tune].label; + if (opts->x_flag_align_jumps && !opts->x_str_align_jumps) + opts->x_str_align_jumps = loongarch_cpu_align[target->cpu_tune].jump; + } /* Set up parameters to be used in prefetching algorithm. */ int simultaneous_prefetches diff --git a/gcc/config/loongarch/loongarch-tune.h b/gcc/config/loongarch/loongarch-tune.h index 72b75f6de3f..3974edf9a90 100644 --- a/gcc/config/loongarch/loongarch-tune.h +++ b/gcc/config/loongarch/loongarch-tune.h @@ -162,14 +162,16 @@ struct loongarch_cache { } }; -/* Alignment for functions and labels for best performance. For new uarchs - the value should be measured via benchmarking. See the documentation for - -falign-functions and -falign-labels in invoke.texi for the format. */ +/* Alignment for functions loops and jumps for best performance. For new + uarchs the value should be measured via benchmarking. See the documentation + for -falign-functions -falign-loops and -falign-jumps in invoke.texi for the + format. */ struct loongarch_align { const char *function; /* default value for -falign-functions */ - const char *label; /* default value for -falign-labels */ + const char *loop; /* default value for -falign-loops */ + const char *jump; /* default value for -falign-jumps */ - loongarch_align () : function (nullptr), label (nullptr) {} + loongarch_align () : function (nullptr), loop (nullptr), jump (nullptr) {} loongarch_align function_ (const char *_function) { @@ -177,9 +179,15 @@ struct loongarch_align { return *this; } - loongarch_align label_ (const char *_label) + loongarch_align loop_ (const char *_loop) { - label = _label; + loop = _loop; + return *this; + } + + loongarch_align jump_ (const char *_jump) + { + jump = _jump; return *this; } };