From patchwork Thu Dec 14 11:26:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiahao Xu X-Patchwork-Id: 178670 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8471157dys; Thu, 14 Dec 2023 03:27:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHFbEqvZPJJdWo4YjuBysySrYH/CxHeKiIkuy9/xlpMYLcsHaOc/Otjez9vs+XSbcPNPfH7 X-Received: by 2002:a05:6808:189b:b0:3b8:b6f6:4f7c with SMTP id bi27-20020a056808189b00b003b8b6f64f7cmr12800354oib.54.1702553241358; Thu, 14 Dec 2023 03:27:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702553241; cv=pass; d=google.com; s=arc-20160816; b=w2aVGMq30yCKXRfyF7dEk51g/PulATUtjXdM2pE1uVZsLhc4Waf7c5bARaMdAQfmmX tak9pBiJQFtrqf3hTXNgkytdvNomIs08Cr2GfUyeVmN45CLSm9JwMLPTuwB64z7eSub6 x5zDqi/hSOFl0PFjA5A9HpSLXzPJbqFuwoXMVvVltLce4+Ssqjh9z4u0MFZS84xO9zTU OcLC17wWlR9wfGXWZWmMCj5cSOqFF/SFchZmNInnFqiR56gt6MzaSCaehKR+GvUdLh3M iXbu1x8DvLyhpq8B9XIJpCjCmq2Fc75qSxOxhas5jpMTTIMLWjJvvwKIT0HrpolXQCn8 wQ5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:arc-filter :dmarc-filter:delivered-to; bh=ZojfNCmh8Hjh1v/hfRXKr/8zykHDTWxYgLH9zGzVjAY=; fh=w+xsGLuzpTj56E0bzPMCc39RWHkBXt2f2AGs+4pGimo=; b=nXELW8V49CbB5NH7vyWlD/EmM1H8EvgbMPT26am53s1bfApSsKsdK1qjSwI+yNSQ7z HjhS8bhnWZg0Z4zPni6toqIQbPlOF373kh1AhRMmgFl65WApdAtvTuyygceH5o2nME96 dolXRjhgUV1Zq8KaDmCBNSLsVU2XXy56+lX9qsxPUuJoGBWIebnMnVUyyGuyeCwM6ige jtbcPsurJsX3kFrk62C2vERYN8xMMPXxsYJldFA5aeiFVyLVizuz31T6AwZw2bjGmX7l Na4sRCT24b/YTj9wns7YmNiLANfXX8SqqBadBCnybdl0HBFZgJh+LTv27BB8xZksEAng Feig== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id dl18-20020ad44e12000000b0067eff5015casi2544682qvb.313.2023.12.14.03.27.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:27:21 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0CF5B385E032 for ; Thu, 14 Dec 2023 11:27:21 +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 792CE3858C2C for ; Thu, 14 Dec 2023 11:26:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 792CE3858C2C 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 792CE3858C2C 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=1702553217; cv=none; b=Q1OEv1jTr53lcB6xuuq97MnImtIJKzoAwaKthfTRyl44lNqSqAWmy7suJ9fXu0tgBS4eP1zLq9W5JY256dop6lU3dnpxA0naPnJMS1p/taOTUq81iyIlkyngn98aBexQ8pJzq8HjMJfdc4fLsI1UNTB0KSPfT/jZPJlcsC7nHhY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702553217; c=relaxed/simple; bh=G9cWQHUWXckhajvutjntEfWBP3Pg/+a0DaW8ON38DBY=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=E0YzfLb90/nZzzpbcNK9GMspAHrgHxQ80ymikoK8nUs1qWxXWM002fQIfBKbLGZfnpkDUf2MNPl3AaoY9XJxRIm+aLvTBc7Cn0lwpMYYyS47KcCbeQEdZBPY4UcK0rPHOjy1ulVZgfTtDnyz1nHyUZMlYrh2MjIgI2X/VHichQU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.10.130.252]) by gateway (Coremail) with SMTP id _____8Cxueh65nplP_0AAA--.5680S3; Thu, 14 Dec 2023 19:26:50 +0800 (CST) Received: from slurm-master.loongson.cn (unknown [10.10.130.252]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxGXN55nplRCgEAA--.7679S4; Thu, 14 Dec 2023 19:26:49 +0800 (CST) From: Jiahao Xu To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i@xen0n.name, chenglulu@loongson.cn, xuchenghua@loongson.cn, Jiahao Xu Subject: [PATCH] LoongArch: Fix incorrect code generation for sad pattern Date: Thu, 14 Dec 2023 19:26:45 +0800 Message-Id: <20231214112645.6454-1-xujiahao@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8AxGXN55nplRCgEAA--.7679S4 X-CM-SenderInfo: 50xmxthkdrqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoWxZr18ZF1rZFy7uF48CrW5CFX_yoW5Wry5pr WDG3WxCF1kJ3WSy3WkG3yUXr4xXry7KFs7uFs8KFZFkw4avrs8uryrKr1aga4qqw4Fvry7 u3Z8AFWjyFy8KrgCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07jUsqXUUUUU= X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785256467635951193 X-GMAIL-MSGID: 1785256467635951193 When I attempt to enable vect_usad_char effective target for LoongArch, some tests fail. These tests fail because the sad pattern generates bad code. This patch to fixed them, for sad patterns, use zero expansion instead of sign expansion for reduction. Currently, we are fixing failed vectorized tests, and in the future, we will enable more tests of "vect" for LoongArch. gcc/ChangeLog: * config/loongarch/lasx.md: Use zero expansion instruction. * config/loongarch/lsx.md: Ditto. diff --git a/gcc/config/loongarch/lasx.md b/gcc/config/loongarch/lasx.md index eeac8cd984b..db6871507e2 100644 --- a/gcc/config/loongarch/lasx.md +++ b/gcc/config/loongarch/lasx.md @@ -5097,8 +5097,8 @@ (define_expand "usadv32qi" rtx t2 = gen_reg_rtx (V16HImode); rtx t3 = gen_reg_rtx (V8SImode); emit_insn (gen_lasx_xvabsd_u_bu (t1, operands[1], operands[2])); - emit_insn (gen_lasx_xvhaddw_h_b (t2, t1, t1)); - emit_insn (gen_lasx_xvhaddw_w_h (t3, t2, t2)); + emit_insn (gen_lasx_xvhaddw_hu_bu (t2, t1, t1)); + emit_insn (gen_lasx_xvhaddw_wu_hu (t3, t2, t2)); emit_insn (gen_addv8si3 (operands[0], t3, operands[3])); DONE; }) @@ -5114,8 +5114,8 @@ (define_expand "ssadv32qi" rtx t2 = gen_reg_rtx (V16HImode); rtx t3 = gen_reg_rtx (V8SImode); emit_insn (gen_lasx_xvabsd_s_b (t1, operands[1], operands[2])); - emit_insn (gen_lasx_xvhaddw_h_b (t2, t1, t1)); - emit_insn (gen_lasx_xvhaddw_w_h (t3, t2, t2)); + emit_insn (gen_lasx_xvhaddw_hu_bu (t2, t1, t1)); + emit_insn (gen_lasx_xvhaddw_wu_hu (t3, t2, t2)); emit_insn (gen_addv8si3 (operands[0], t3, operands[3])); DONE; }) diff --git a/gcc/config/loongarch/lsx.md b/gcc/config/loongarch/lsx.md index dbdb423011b..5e5e2503636 100644 --- a/gcc/config/loongarch/lsx.md +++ b/gcc/config/loongarch/lsx.md @@ -3468,8 +3468,8 @@ (define_expand "usadv16qi" rtx t2 = gen_reg_rtx (V8HImode); rtx t3 = gen_reg_rtx (V4SImode); emit_insn (gen_lsx_vabsd_u_bu (t1, operands[1], operands[2])); - emit_insn (gen_lsx_vhaddw_h_b (t2, t1, t1)); - emit_insn (gen_lsx_vhaddw_w_h (t3, t2, t2)); + emit_insn (gen_lsx_vhaddw_hu_bu (t2, t1, t1)); + emit_insn (gen_lsx_vhaddw_wu_hu (t3, t2, t2)); emit_insn (gen_addv4si3 (operands[0], t3, operands[3])); DONE; }) @@ -3485,8 +3485,8 @@ (define_expand "ssadv16qi" rtx t2 = gen_reg_rtx (V8HImode); rtx t3 = gen_reg_rtx (V4SImode); emit_insn (gen_lsx_vabsd_s_b (t1, operands[1], operands[2])); - emit_insn (gen_lsx_vhaddw_h_b (t2, t1, t1)); - emit_insn (gen_lsx_vhaddw_w_h (t3, t2, t2)); + emit_insn (gen_lsx_vhaddw_hu_bu (t2, t1, t1)); + emit_insn (gen_lsx_vhaddw_wu_hu (t3, t2, t2)); emit_insn (gen_addv4si3 (operands[0], t3, operands[3])); DONE; })