From patchwork Sat Dec 9 17:03:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1874057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=xry111.site header.i=@xry111.site header.a=rsa-sha256 header.s=default header.b=mQ+qO0vk; 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 4SnZBX1B46z23n0 for ; Sun, 10 Dec 2023 04:05:08 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2AC72385842E for ; Sat, 9 Dec 2023 17:05:06 +0000 (GMT) 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 EAB7C385842C for ; Sat, 9 Dec 2023 17:04:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EAB7C385842C Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EAB7C385842C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=89.208.246.23 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702141468; cv=none; b=eNp+Pxt1R0BNCuaSVcVE3maOwkdKnoY22sDE4qucUxx+W/qz0JL02JDf06z5qktKwc9TPiFQJwFTNS124mR62Agi4hmQTItPJKOJRB/SvSoIZ+5uCltXw8EflKlk/e1CX6IpDDgvVn+xYQ9gKsOSXMe7pwPYnyl+F8IpemnpY9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702141468; c=relaxed/simple; bh=RsOboWPY7MANOxnELrYH7iMzTRvogzHHg1wl9Ig2wHM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=fl16BuDNY2/D4iV6LbkkiD7tj5qGSHsQDYP8jZiEqzVVmwaoQ7yaxunCxhw/7Rjm2SM6NhT1+r+BMMB1KLNfNtDHCy6dMt4RXPc3CyYJ4zIEGa+PllC/rhTHcCsz5/cL8HawXgd/GpQVLNs+XcZbbhsQhNx2ZewjcPVme8A+2Dw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1702141466; bh=RsOboWPY7MANOxnELrYH7iMzTRvogzHHg1wl9Ig2wHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mQ+qO0vkDyBBuwj9LyX7Q0Sae/pAmhvOc71FPOZNexk7RWfwKwEkwgN6y4JU/3aN9 EtypT2lyQAv35lxLeahFIbv3oF1Ock8EDiv0VCoeWNCmpQoE6qnwCpH2iULx37GgqL c1zYFcyKdOGAji96wh/IsKpeYU1aiV5kbEwqM3DQ= Received: from stargazer.. (unknown [IPv6:240e:358:1144:3a00:dc73:854d:832e:5]) (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 55B5466940; Sat, 9 Dec 2023 12:04:22 -0500 (EST) From: Xi Ruoyao To: gcc-patches@gcc.gnu.org Cc: chenglulu , i@xen0n.name, xuchenghua@loongson.cn, c@jia.je, Xi Ruoyao Subject: [PATCH 3/3] LoongArch: Add alslsi3_extend Date: Sun, 10 Dec 2023 01:03:48 +0800 Message-ID: <20231209170347.12601-5-xry111@xry111.site> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231209170347.12601-2-xry111@xry111.site> References: <20231209170347.12601-2-xry111@xry111.site> MIME-Version: 1.0 X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_FROM, 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.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 Following the instruction cost fix, we are generating alsl.w $a0, $a0, $a0, 4 instead of li.w $t0, 17 mul.w $a0, $t0 for "x * 4", because alsl.w is 4 times faster than mul.w. But we didn't have a sign-extending pattern for alsl.w, causing an extra slli.w instruction generated to sign-extend $a0. Add the pattern to remove the redundant extension. gcc/ChangeLog: * config/loongarch/loongarch.md (alslsi3_extend): New define_insn. --- gcc/config/loongarch/loongarch.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md index afbf201d4d0..7b26d15aa4e 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -2869,6 +2869,18 @@ (define_insn "alsl3" [(set_attr "type" "arith") (set_attr "mode" "")]) +(define_insn "alslsi3_extend" + [(set (match_operand:DI 0 "register_operand" "=r") + (sign_extend:DI + (plus:SI + (ashift:SI (match_operand:SI 1 "register_operand" "r") + (match_operand 2 "const_immalsl_operand" "")) + (match_operand:SI 3 "register_operand" "r"))))] + "" + "alsl.w\t%0,%1,%3,%2" + [(set_attr "type" "arith") + (set_attr "mode" "SI")]) + ;; Reverse the order of bytes of operand 1 and store the result in operand 0.