From patchwork Tue Jul 2 03:21:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cheng X-Patchwork-Id: 1954997 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=8.43.85.97; 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 [8.43.85.97]) (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 4WCpBJ6pL9z1xpc for ; Tue, 2 Jul 2024 13:22:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9B002387543F for ; Tue, 2 Jul 2024 03:22:28 +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 669623858C50 for ; Tue, 2 Jul 2024 03:22:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 669623858C50 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 669623858C50 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=1719890531; cv=none; b=VF48Rmbl6wt2OCGhi388/KSCXP15kQsCAZRzy42nrpZ92RE596xJ7xR0+OOSG7juP7oNm+jzMGVIDvUT58jLAVduoKL9oyyTfMKbtwe5ec/yX1fxRd3YKdaT0q08l6eJPKhEii8v0jwdr0D5l5ssfh4joGhqH+Rpai0BhuhZ5tA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719890531; c=relaxed/simple; bh=cTvtEmwbsrCil1x54XWmIty2LKOsDEENjNVxhN555iM=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=YOabh68Ul/FseH7gY8SGvyrGx9MQgrbaos8R4a1L0X2lqElsPKxKxBeDeFyVGXOEkEgfKJFjjgkcpFF+Y+waRiQAD2341P+jN3xoRhHLVaeBzL6BNM2Df32EPCVqe9l4qb21W0HUKz6a4rb3XIl/QYRL9csn2nUnrFhv1wa6TDw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8AxH_FecoNmvgQAAA--.178S3; Tue, 02 Jul 2024 11:22:07 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxNMVccoNm2io4AA--.54655S2; Tue, 02 Jul 2024 11:22:06 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i@xen0n.name, xuchenghua@loongson.cn, chenglulu@loongson.cn Subject: [PATCH 1/2] LoongArch: Fix explicit-relocs-{extreme-, }tls-desc.c tests. Date: Tue, 2 Jul 2024 11:21:59 +0800 Message-Id: <20240702032200.26875-1-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxNMVccoNm2io4AA--.54655S2 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW7Kw1UAw13Xw4xur43uF17urX_yoW8tr18pa srZw17Kr48J3yvkw18J3WfWr1fua1qgry2934fXw4IyF17G393tF1ktw47JF1UJayUW39x XF4fu34fXF12q3cCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r126r1DMcIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I 0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07UMpBfUUUUU= X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, 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 After r15-1579, ADD and LD/ST pairs will be merged into LDX/STX. Cause these two tests to fail. To guarantee that these two tests pass, add the compilation option '-fno-late-combine-instructions'. gcc/testsuite/ChangeLog: * gcc.target/loongarch/explicit-relocs-extreme-tls-desc.c: Add compilation options '-fno-late-combine-instructions'. * gcc.target/loongarch/explicit-relocs-tls-desc.c: Likewise. --- .../gcc.target/loongarch/explicit-relocs-extreme-tls-desc.c | 2 +- gcc/testsuite/gcc.target/loongarch/explicit-relocs-tls-desc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.target/loongarch/explicit-relocs-extreme-tls-desc.c b/gcc/testsuite/gcc.target/loongarch/explicit-relocs-extreme-tls-desc.c index 3797556e1e6..e9eb0d6f703 100644 --- a/gcc/testsuite/gcc.target/loongarch/explicit-relocs-extreme-tls-desc.c +++ b/gcc/testsuite/gcc.target/loongarch/explicit-relocs-extreme-tls-desc.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fPIC -mexplicit-relocs -mtls-dialect=desc -mcmodel=extreme" } */ +/* { dg-options "-O2 -fPIC -mexplicit-relocs -mtls-dialect=desc -mcmodel=extreme -fno-late-combine-instructions" } */ __thread int a __attribute__((visibility("hidden"))); extern __thread int b __attribute__((visibility("default"))); diff --git a/gcc/testsuite/gcc.target/loongarch/explicit-relocs-tls-desc.c b/gcc/testsuite/gcc.target/loongarch/explicit-relocs-tls-desc.c index f6690309156..fed478458a3 100644 --- a/gcc/testsuite/gcc.target/loongarch/explicit-relocs-tls-desc.c +++ b/gcc/testsuite/gcc.target/loongarch/explicit-relocs-tls-desc.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fPIC -mexplicit-relocs -mtls-dialect=desc" } */ +/* { dg-options "-O2 -fPIC -mexplicit-relocs -mtls-dialect=desc -fno-late-combine-instructions" } */ __thread int a __attribute__((visibility("hidden"))); extern __thread int b __attribute__((visibility("default"))); From patchwork Tue Jul 2 03:22:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cheng X-Patchwork-Id: 1954998 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 4WCpCF5hQDz1xqd for ; Tue, 2 Jul 2024 13:23:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 14BA43835406 for ; Tue, 2 Jul 2024 03:23:17 +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 66ADB3858C32 for ; Tue, 2 Jul 2024 03:22:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 66ADB3858C32 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 66ADB3858C32 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=1719890531; cv=none; b=fXuJctZsp6i/sfMljHOnBxxR1Ogi5T9OzWDVd3mGDXFxFeLHrQvuxHmrBw8S5tcS23dK0Jul9mDxWU8j0Atz1nfDTo9m6dPvCq8kwo9vg/zhhiyhjDdOBtCMt0gG0ioKC9+PXtdhVpNiTvz85BmAXhfvVU4hjeyY6vEAttBZydo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719890531; c=relaxed/simple; bh=qi1prSKBN8Lw07jNEORS9dSakft7kAkgxh5QvM8jBf8=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=Ae27cq87fwwr6yS0hTI0UIb6IBsLSKAHlyvnvAX1WoXz/u2dEPi36ErQcqHom8faA3gbNep0e44OY8F9zSHwp9HpzxxvEMzSo3CVTcO/t8IeKFDaBk5DnCeWiq3OZ5UTj13AP+tIjZ79S9Z1j3tT8U9Em1UPU+NVmIh96xS9DQ8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8BxL_FfcoNmwQQAAA--.168S3; Tue, 02 Jul 2024 11:22:07 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxNMVccoNm2io4AA--.54655S3; Tue, 02 Jul 2024 11:22:06 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i@xen0n.name, xuchenghua@loongson.cn, chenglulu@loongson.cn Subject: [PATCH 2/2] LoongArch: Define loongarch_insn_cost and set the cost of movcf2gr and movgr2cf. Date: Tue, 2 Jul 2024 11:22:00 +0800 Message-Id: <20240702032200.26875-2-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240702032200.26875-1-chenglulu@loongson.cn> References: <20240702032200.26875-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxNMVccoNm2io4AA--.54655S3 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW7tr4kJrWxGry7Kr4xuryxtFc_yoW8uFW8pr 97Arnxtr48Grs3GFs3ta45X398Ars7WF42gay3t3yrAa17Xr1UZ3WvkFyvqFyUXa1rZrW7 Zr1fKa17uF4UA3gCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r126r1DMcIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I 0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07j83kZUUUUU= X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, 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 The following two FAIL items have been fixed: FAIL: gcc.target/loongarch/movcf2gr-via-fr.c scan-assembler movcf2fr\\t\\\\\$f[0-9]+,\\\\\$fcc FAIL: gcc.target/loongarch/movcf2gr-via-fr.c scan-assembler movfr2gr\\\\.s\\t\\\\\$r4 gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_insn_cost): New function. (TARGET_INSN_COST): New macro. --- gcc/config/loongarch/loongarch.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 0fb547e00f4..cf21c365605 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -4372,6 +4372,34 @@ loongarch_address_cost (rtx addr, machine_mode mode, return loongarch_address_insns (addr, mode, false); } +/* Implement TARGET_INSN_COST. */ + +static int +loongarch_insn_cost (rtx_insn *insn, bool speed) +{ + rtx x = PATTERN (insn); + int cost = pattern_cost (x, speed); + + /* On LA464, prevent movcf2fr and movfr2gr from merging into movcf2gr. */ + if (TARGET_uARCH_LA464 && GET_CODE (x) == SET + && GET_MODE (XEXP (x, 0)) == FCCmode) + { + rtx dest, src; + dest = XEXP (x, 0); + src = XEXP (x, 1); + + if (REG_P (dest) && REG_P (src)) + { + if (GP_REG_P (REGNO (dest)) && FCC_REG_P (REGNO (src))) + cost = COSTS_N_INSNS (7); + else if (FCC_REG_P (REGNO (dest)) && GP_REG_P (REGNO (src))) + cost = COSTS_N_INSNS (15); + } + } + return cost; +} + + /* Return one word of double-word value OP, taking into account the fixed endianness of certain registers. HIGH_P is true to select the high part, false to select the low part. */ @@ -11105,6 +11133,8 @@ loongarch_asm_code_end (void) #define TARGET_RTX_COSTS loongarch_rtx_costs #undef TARGET_ADDRESS_COST #define TARGET_ADDRESS_COST loongarch_address_cost +#undef TARGET_INSN_COST +#define TARGET_INSN_COST loongarch_insn_cost #undef TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST #define TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST \ loongarch_builtin_vectorization_cost