Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2231303/?format=api
{ "id": 2231303, "url": "http://patchwork.ozlabs.org/api/patches/2231303/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260430144210.30929-1-xry111@xry111.site/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260430144210.30929-1-xry111@xry111.site>", "list_archive_url": null, "date": "2026-04-30T14:41:46", "name": "LoongArch: eliminate redundant extension after ctz.w", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "b9e692c26728f09b909ccf0e10089c84e0a0ad7a", "submitter": { "id": 84026, "url": "http://patchwork.ozlabs.org/api/people/84026/?format=api", "name": "Xi Ruoyao", "email": "xry111@xry111.site" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260430144210.30929-1-xry111@xry111.site/mbox/", "series": [ { "id": 502319, "url": "http://patchwork.ozlabs.org/api/series/502319/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=502319", "date": "2026-04-30T14:41:46", "name": "LoongArch: eliminate redundant extension after ctz.w", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/502319/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2231303/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2231303/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=xry111.site header.i=@xry111.site header.a=rsa-sha256\n header.s=default header.b=acskneWY;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=xry111.site header.i=@xry111.site header.a=rsa-sha256\n header.s=default header.b=acskneWY", "sourceware.org;\n dmarc=pass (p=reject dis=none) header.from=xry111.site", "sourceware.org; spf=pass smtp.mailfrom=xry111.site", "server2.sourceware.org;\n arc=none smtp.remote-ip=89.208.246.23" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g5xk43ptXz1yHZ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 00:43:24 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 5EDC7436F7F8\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 14:43:03 +0000 (GMT)", "from xry111.site (xry111.site [89.208.246.23])\n by sourceware.org (Postfix) with ESMTPS id 398054BAD14B\n for <gcc-patches@gcc.gnu.org>; Thu, 30 Apr 2026 14:42:37 +0000 (GMT)", "from stargazer (unknown\n [IPv6:240e:45d:230:59b8:30ac:66a4:df02:3faf])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n (Client did not present a certificate)\n (Authenticated sender: xry111@xry111.site)\n by xry111.site (Postfix) with ESMTPSA id 5A1E765992;\n Thu, 30 Apr 2026 10:42:33 -0400 (EDT)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 5EDC7436F7F8", "OpenDKIM Filter v2.11.0 sourceware.org 398054BAD14B" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 398054BAD14B", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 398054BAD14B", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777560157; cv=none;\n b=DosO6nGv4+GpSZp8vqjYc4Ag5xTNTJ6610vjv+ecy5YvwylSGzHtAyn43kFS+q0/aqdbk8S38pOpSMzWy4qDutxIEBGU72fHNq3PW42hdbwN93fyKomjZTgeID8xOtWtKzxuQHSTBHEofuJW/H5ZVFFemeB01/MbDjgEFfef8E4=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777560157; c=relaxed/simple;\n bh=xThdeOENBFvgWwPC7TaZxJA6S2qgzG/vr2v/ySlTWB4=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=pP6SHp5FBEHFiVbrWrufUEBE+LysZLFILzvBlDIv7j8hwDt7zEzF6U3Rf+GdCkR9h9EZJTPXSIr/6WKK1Qqki2r6VCjSuFQUGcBYU34mV8SE3RuzRck/k+lOMM0YkrGAkctXeQtxAPJ5vcmOmdjOf0cAh+QAFtXqLcrfpBhxCaw=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=xry111.site;\n s=default; t=1777560156;\n bh=7T/Gb/7C9xDYq4Lrutt/QSFD8qZ1/ACP4wOgB22urCE=;\n h=From:To:Cc:Subject:Date:From;\n b=acskneWYObhAUTHQ6G9DRb+qxtDIikv31sTIg71jzXTLKivJuAYbUEivfRrPYENd1\n FgZGbQE3c54KcIdOq2EWmY4UnG5DVjprg2hZm+PPXIPyx11wX8eo9HXsG+aJkISsEB\n fk+mjKfZyCLbeMbz7l38nX3Sb04vPeZcCCIhzv7E=", "From": "Xi Ruoyao <xry111@xry111.site>", "To": "gcc-patches@gcc.gnu.org", "Cc": "Lulu Cheng <chenglulu@loongson.cn>, WANG Xuerui <i@xen0n.name>,\n Mingcong Bai <jeffbai@aosc.io>, Zixing Liu <liushuyu@aosc.io>,\n Xi Ruoyao <xry111@xry111.site>", "Subject": "[PATCH] LoongArch: eliminate redundant extension after ctz.w", "Date": "Thu, 30 Apr 2026 22:41:46 +0800", "Message-ID": "<20260430144210.30929-1-xry111@xry111.site>", "X-Mailer": "git-send-email 2.54.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "gcc-patches@gcc.gnu.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>", "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>", "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "The ctz.w instruction writes to the entire $rd. So due to the range of\nthe CTZ result ([0, 32]), $rd is already both sign-extended and\nzero-extended from its lower half. But in pr90838.c we can see two\nredundant sign-extension (slli.w ...,0). Now get rid of them.\n\nThe \"andi\" instructions in pr90393.c are really needed, because the\nsource code logic should produce 0 for zero input, but the ctz.[dw]\ninstructions actually produce 64/32.\n\ngcc/\n\n\t* config/loongarch/loongarch.md (*ctzsi2_extend): New\n\tdefine_insn.\n\ngcc/testsuite/\n\n\t* gcc.dg/pr90838.c: Adjust expectation for LoongArch.\n---\n\nBootstrapped and regtested on loongarch64-linux-gnu. Ok for trunk?\n\n gcc/config/loongarch/loongarch.md | 9 +++++++++\n gcc/testsuite/gcc.dg/pr90838.c | 2 +-\n 2 files changed, 10 insertions(+), 1 deletion(-)", "diff": "diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md\nindex 77b3298078a..f8693b7f593 100644\n--- a/gcc/config/loongarch/loongarch.md\n+++ b/gcc/config/loongarch/loongarch.md\n@@ -1452,6 +1452,15 @@ (define_insn \"ctz<mode>2\"\n [(set_attr \"type\" \"clz\")\n (set_attr \"mode\" \"<MODE>\")])\n \n+(define_insn \"*ctzsi2_extend\"\n+ [(set (match_operand:DI 0 \"register_operand\" \"=r\")\n+\t(any_extend:DI\n+\t (ctz:SI (match_operand:SI 1 \"register_operand\" \"r\"))))]\n+ \"TARGET_64BIT\"\n+ \"ctz.w\\t%0,%1\"\n+ [(set_attr \"type\" \"clz\")\n+ (set_attr \"mode\" \"SI\")])\n+\n ;;\n ;; ....................\n ;;\ndiff --git a/gcc/testsuite/gcc.dg/pr90838.c b/gcc/testsuite/gcc.dg/pr90838.c\nindex 99c413e2627..fc7a045d53f 100644\n--- a/gcc/testsuite/gcc.dg/pr90838.c\n+++ b/gcc/testsuite/gcc.dg/pr90838.c\n@@ -87,4 +87,4 @@ int ctz4 (unsigned long x)\n /* { dg-final { scan-tree-dump-times {= \\.CTZ} 4 \"forwprop2\" { target { loongarch64*-*-* } } } } */\n /* { dg-final { scan-assembler-times \"ctz.d\\t\" 1 { target { loongarch64*-*-* } } } } */\n /* { dg-final { scan-assembler-times \"ctz.w\\t\" 3 { target { loongarch64*-*-* } } } } */\n-/* { dg-final { scan-assembler-times \"\\(andi|slli.w\\)\\t\" 4 { target { loongarch64*-*-* } } } } */\n+/* { dg-final { scan-assembler-times \"andi\\t\" 2 { target { loongarch64*-*-* } } } } */\n", "prefixes": [] }