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: 84825 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2800555vqo; Tue, 18 Apr 2023 05:18:57 -0700 (PDT) X-Google-Smtp-Source: AKy350YmJmh++xXR4pDmCmjl0cXHiYplpP2dftwH9OeEO7P/tstjEAFoHZ/RcMvYBn7pZ1pDSDym X-Received: by 2002:a17:906:711:b0:94f:236b:9e3a with SMTP id y17-20020a170906071100b0094f236b9e3amr8538193ejb.3.1681820337154; Tue, 18 Apr 2023 05:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681820337; cv=none; d=google.com; s=arc-20160816; b=qKb8Qzi3pcVAMjBllXBPryI1GGh9yMBijkMcImMSWqa9Ulz3BizUq4Sp+VfCvaMFGn rW1urOo8MAuvCz2+YHEmMu7hwq3ou+9ucbMWyupm0EZZQa9uCjCWm1Kx8RjkUDUxxSSK f7J2R4+xs7dBnvNeScI2vJEKvSKZveqzDA6d7F1YRBtA1agtS84S/YInub8ngoEpGUTq rrUKLEhKHPOaaktKETPAgZtHc11owcayJu+D+HPLNz2B8rcWZ+zwerYsodUcPf9jX2ZZ Gky3KPfdYnZr5kUD7ruClLQc1u+MjnihEi+uxkJEKJmKSvGMkW2ZwdTH+RW4aJGwVaeE 9VUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=B0XBmFtIZLM08m9sNRsYF7/V3y0rKy/vxlSkBXunWZM=; b=wuN4K4wrEsKTIiZeXChLCoHOuG1F64Qs/DTOjVTF7RYTeEYNwMBsLuLsZPUPJrzkE5 7AwUjWl3p//8qw9Ne1WN+pJL/WfhyiXYyz5UbxGk0kcXRqphGiAczLRhAvUagPkelzRO 6ujqomAy2y6g28KNo2/EW/o0JZC77wjLHKiJKp+cmB6UQh9NvaVQsmhRhrrqzgFrs6FM tpxffNaKH9lMO6eYquxbhm603C2GUC+jEiwnQp7VTIILsyxnGKqyVb6pm+shYH1vhWV3 1ATY/BBg+pdVZX/TtCeWcUbQQgnvsm8Qza5mzWlcNepukzXYFv30p9+HYn8g2QKUY4F0 QuYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xjtbTU8Z; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h19-20020a17090791d300b0094ef99db98dsi7661459ejz.654.2023.04.18.05.18.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 05:18:57 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xjtbTU8Z; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 17BC83858288 for ; Tue, 18 Apr 2023 12:18:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17BC83858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681820336; 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=xjtbTU8ZU7/RFE1pOZiirbj2UZrkqFTiKUhp/adP/Mda1fhbZBrmUPdPNGAKn8LfY Xr9sz+VjxBgV/lYIMZz+uFPKj5V3Oj4gesV9SrsWovNAXyZ1zsOQvnmGbP74jzx8J4 fdzBDAIXrai5xLPwukVHqy1WpCZ5pbRiqzDnOTlY= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763516441601989087?= X-GMAIL-MSGID: =?utf-8?q?1763516441601989087?= 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");