From patchwork Tue Apr 18 12:17:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1770127 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=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=ejgdPtLR; dkim-atps=neutral Received: from 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q12yN3M0Zz1yZy for ; Tue, 18 Apr 2023 22:18:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A9433858D28 for ; Tue, 18 Apr 2023 12:18:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A9433858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681820311; bh=B0XBmFtIZLM08m9sNRsYF7/V3y0rKy/vxlSkBXunWZM=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ejgdPtLRILDbpXtfr0Ec9NSjeuSGPGLc5TyDTNALa1G9b5/IrbgX/9qcltNUKqray ULDcdHcMPn59GhAoumxg41aEMMYQD8uW37uHmSuZuh4C+UeiNAYzVkALoHPrQfDasr JA1c/VAmA7dtp3pVSd1PAIPFfq5yRrM1VcPGuFZU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 70BDA3858D1E for ; Tue, 18 Apr 2023 12:18:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 70BDA3858D1E Received: from stargazer.. (unknown [115.155.1.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 1731365EBC; Tue, 18 Apr 2023 08:18:05 -0400 (EDT) To: gcc-patches@gcc.gnu.org Cc: Lulu Cheng , WANG Xuerui , Chenghua Xu , Xi Ruoyao Subject: [PATCH] LoongArch: Set 4 * (issue rate) as the default for -falign-functions and -falign-loops Date: Tue, 18 Apr 2023 20:17:53 +0800 Message-Id: <20230418121753.50830-1-xry111@xry111.site> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_FROM, RCVD_IN_BARRACUDACENTRAL, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xi Ruoyao via Gcc-patches From: Xi Ruoyao Reply-To: Xi Ruoyao Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" According to Xuerui's LLVM changeset [1], doing so can make a significant performace gain. Bootstrapped and regtested on loongarch64-linux-gnu. Ok for GCC 14? [1]:https://reviews.llvm.org/D148622 gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_option_override_internal): If -falign-functions is used but the alignment is not explicitly specified, set it to 4 * loongarch_issue_rate (). Likewise for -falign-loops. --- gcc/config/loongarch/loongarch.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 06fc1cd0604..6552484de7c 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -6236,6 +6236,17 @@ loongarch_option_override_internal (struct gcc_options *opts) && !opts->x_optimize_size) opts->x_flag_prefetch_loop_arrays = 1; + /* Align functions and loops to (issue rate) * (insn size) to improve + the throughput of the fetching units. */ + char *align = XNEWVEC (char, 16); + sprintf (align, "%d", loongarch_issue_rate () * 4); + + if (opts->x_flag_align_functions && !opts->x_str_align_functions) + opts->x_str_align_functions = align; + + if (opts->x_flag_align_loops && !opts->x_str_align_loops) + opts->x_str_align_loops = align; + if (TARGET_DIRECT_EXTERN_ACCESS && flag_shlib) error ("%qs cannot be used for compiling a shared library", "-mdirect-extern-access");