get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.1/patches/2228957/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2228957,
    "url": "http://patchwork.ozlabs.org/api/1.1/patches/2228957/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/2a921c9d-c312-4ccd-afca-d97813432403@oss.qualcomm.com/",
    "project": {
        "id": 17,
        "url": "http://patchwork.ozlabs.org/api/1.1/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
    },
    "msgid": "<2a921c9d-c312-4ccd-afca-d97813432403@oss.qualcomm.com>",
    "date": "2026-04-27T14:52:58",
    "name": "[to-be-committed,V3,PR,target/121268] ",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "f2142626a7c19e6a183de314489526e33d670acd",
    "submitter": {
        "id": 92310,
        "url": "http://patchwork.ozlabs.org/api/1.1/people/92310/?format=api",
        "name": "Jeffrey Law",
        "email": "jeffrey.law@oss.qualcomm.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/2a921c9d-c312-4ccd-afca-d97813432403@oss.qualcomm.com/mbox/",
    "series": [
        {
            "id": 501666,
            "url": "http://patchwork.ozlabs.org/api/1.1/series/501666/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=501666",
            "date": "2026-04-27T14:52:58",
            "name": "[to-be-committed,V3,PR,target/121268] ",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/501666/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2228957/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2228957/checks/",
    "tags": {},
    "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=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=aUalK9UP;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n header.a=rsa-sha256 header.s=google header.b=eTPPj0Zo;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.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=fail reason=\"signature verification failed\" (2048-bit key,\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=aUalK9UP;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key,\n unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n header.a=rsa-sha256 header.s=google header.b=eTPPj0Zo",
            "sourceware.org; dmarc=none (p=none dis=none)\n header.from=oss.qualcomm.com",
            "sourceware.org;\n spf=pass smtp.mailfrom=oss.qualcomm.com",
            "server2.sourceware.org;\n arc=none smtp.remote-ip=205.220.180.131"
        ],
        "Received": [
            "from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 4g465F0rktz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 00:53:35 +1000 (AEST)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 10AC74BAD171\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 14:53:34 +0000 (GMT)",
            "from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com\n [205.220.180.131])\n by sourceware.org (Postfix) with ESMTPS id 4A0674B9DB46\n for <gcc-patches@gcc.gnu.org>; Mon, 27 Apr 2026 14:53:04 +0000 (GMT)",
            "from pps.filterd (m0279870.ppops.net [127.0.0.1])\n by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 63RB724A1237213\n for <gcc-patches@gcc.gnu.org>; Mon, 27 Apr 2026 14:53:02 GMT",
            "from mail-dl1-f69.google.com (mail-dl1-f69.google.com\n [74.125.82.69])\n by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dt6n4gta6-1\n (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n for <gcc-patches@gcc.gnu.org>; Mon, 27 Apr 2026 14:53:02 +0000 (GMT)",
            "by mail-dl1-f69.google.com with SMTP id\n a92af1059eb24-12c8d7d4a79so9231008c88.1\n for <gcc-patches@gcc.gnu.org>; Mon, 27 Apr 2026 07:53:02 -0700 (PDT)",
            "from [172.31.0.17] ([136.38.201.137])\n by smtp.gmail.com with ESMTPSA id\n a92af1059eb24-12dbaab165bsm29667790c88.6.2026.04.27.07.52.59\n for <gcc-patches@gcc.gnu.org>\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Mon, 27 Apr 2026 07:52:59 -0700 (PDT)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org 10AC74BAD171",
            "OpenDKIM Filter v2.11.0 sourceware.org 4A0674B9DB46"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 4A0674B9DB46",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 4A0674B9DB46",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777301584; cv=none;\n b=PXEdQFsYY8Mwh62W6Nr58v74NPKdheofxY55KXYxwvNJQ7jKmfdsbHrLaoguLSXpvREB7E0626JeyyY64B2ON1GauCRT4gmmxJ5h6f0tYv/FKEWjUr5QbgjVHBmTOOPgwexxQdG+u61hAwdQj/nY6k+issAPDwZzqRUVVkh88No=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777301584; c=relaxed/simple;\n bh=ErJ3bSj7f2oohp4lq0iuX5ApcJTdz55X0YQ7uFEBUVE=;\n h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version:To:\n From:Subject;\n b=PsTV5v6vIO9G7AfNkf1coKOpAmSozEuBrLPZyiJmxomVoQ/7DS4KbYpO7N6qXFYRmy8x9TU7QqLjJOAd1tXWKOqTI3mxK9iQqdCayillLjFB5+I/LO9tfJmmKYldybMWYGrsMojTRHWTGNRW3EHYa5K//Wr3jCwdUdjETDATMQg=",
        "ARC-Authentication-Results": "i=1; server2.sourceware.org",
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=\n content-type:date:from:message-id:mime-version:subject:to; s=\n qcppdkim1; bh=6BE5UUy0dWYpdwbsGb49NUyEi6AdvX2+6FYVzcGfEok=; b=aU\n alK9UP0g+otlMTG58QWOgkYmeH5sMjTVLocbfQu7LnMWW4nYDws6FG4/G7FAurtY\n ARjbeFbZ6EjJqElp+Xw2W1eoZp69ZUkAL/J5sNcOy7gMUXDd5DC+1LniEPoaXhpF\n 28oW1/f1JipDm8eQrTXftxd0HCqIP6eFgONPNT93xPchediZwWlYFICj3tacDhCi\n DFeAK3I9bldOIluDNwH0eIsHFIfYtmT/8XBN41ILESliPRAhkAdhgi1TgNn89o56\n GuVh/2aW8dmsQ6VyI96Z03ZYSSEqXLuS02CmtvsRbVn/KOvGOCZOWP09f9JHomXh\n uw5U6NS5ShPEGxQv4nuQ==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=oss.qualcomm.com; s=google; t=1777301581; x=1777906381; darn=gcc.gnu.org;\n h=subject:from:to:content-language:user-agent:mime-version:date\n :message-id:from:to:cc:subject:date:message-id:reply-to;\n bh=6BE5UUy0dWYpdwbsGb49NUyEi6AdvX2+6FYVzcGfEok=;\n b=eTPPj0ZoXELyVAhgzbi1oY/jlx+qWU7nBDxm7uuyx9eX6PoEctb8cTogQmmTjLU/YX\n s9ufcQvag4kMTEXFnFgg9j59F6VhAP2KqHjDAYn1+XS8d8KelKbjH/CKe11S6cyeupGp\n 4XtgApeCNk4XXBGIxjZ4YP8YPCxGa6F86W7pYYERT9VtoCUy5x82Dc/kKHqgRVBwogNv\n Z1+mihIi0jvGOGZ5Uo3Fjwp9ComhDd2LlPPV+DOpbcMCKh0xoN55I4CW0Eikf6AlA3Fi\n FJF1s+VBLw60zRMMQF5eAXYHsW8btMkIkRKW/nduzu+toIdNTyAODZL2iv6Kh4NNiKwA\n 21yQ=="
        ],
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777301581; x=1777906381;\n h=subject:from:to:content-language:user-agent:mime-version:date\n :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=6BE5UUy0dWYpdwbsGb49NUyEi6AdvX2+6FYVzcGfEok=;\n b=HXCRykorXeelY02RbPeu9nBPP59/Qe2gOFfAYJOONTag14bwFTDIXrivenqJZ++Yqi\n Og11H6EqEARIQpgpQyHz9FiLWsSn8RoracLQdj94PSSFmoO/yR+U3Ee1is1wx5M3ngx0\n o/r99aQbF7HfjFeazmLvpsXsWu068M9Q48oisy8HXU5M68NK3f+5A44TaoPX2+ff+9/f\n c7AAnmC3Vuf59u60nrp+I/AXqu9/Es6CLjw8o4u8SBmgoB7bN3IT5E4dxWad0UYVIMlK\n OZ20DdPP4UVqVrZEyNwo05P7qtCQV45kUQTFS5/cQPd1C7ksEL6jIK47XyWf+z1ankyk\n BzeQ==",
        "X-Gm-Message-State": "AOJu0YwagaU/PK00ISilE3nRg6faI/y9mpMz6eNR7RGcFR8TLUSANILw\n YDUhWwy/nSqHVlp7BU4+GFb1NylOIUjc4vsY4lHrnDOgkVE3y849qmLV1X1iw7U0hlJQvtAo1jn\n C/DmLtxbO+v2wjzy+K4knU6X5I8o8C9WU8pasr8WzfynPXVoqY5ixAFOovPvjEVPCT6f1",
        "X-Gm-Gg": "AeBDietD7zgDZoc/+BjdFHGFFYQOVpjkE0SnpBD6KWQGVhCsLYGZrfkNBdYiyFzHfKa\n 5+hjFYG3kPgEiB7Ig/64+u71qxraCeTGbcFOuMz6NtoL0m+PjAHWgE2hU6wsmANrJ49sRZGDG4W\n hQdQw4i/Soq1e05eSg1ERh4u/xCRjfFayv/NHBqmWRl0rubGoDKGzeKZcj4JDtst6KEEO0qkSAw\n EMLGsxUZrWWUXEj5ahOFtebAqgU+jzLOuy+ZMoAETvj78w8iBilDL/9qcN36kKNEvmmWTRJvYKd\n 7j1Xkml0vCPbphW5avAd63dbHG2rQED0waSYN/YJcAqsPnivNM+hBxiXTwlpOYubit3tuiQoRMd\n e24WsHqQvWRS5/nLW1mu5i6w6Q7WRycG2ht7zWZFDcfW3K5Fl+7ILNkRVoY6v",
        "X-Received": [
            "by 2002:a05:7022:4583:b0:12c:5e48:4bcc with SMTP id\n a92af1059eb24-12c73f835cbmr22012383c88.14.1777301581016;\n Mon, 27 Apr 2026 07:53:01 -0700 (PDT)",
            "by 2002:a05:7022:4583:b0:12c:5e48:4bcc with SMTP id\n a92af1059eb24-12c73f835cbmr22012355c88.14.1777301579978;\n Mon, 27 Apr 2026 07:52:59 -0700 (PDT)"
        ],
        "Content-Type": "multipart/mixed; boundary=\"------------b9T0MgajfPqaQ6oJDdTnv9fx\"",
        "Message-ID": "<2a921c9d-c312-4ccd-afca-d97813432403@oss.qualcomm.com>",
        "Date": "Mon, 27 Apr 2026 08:52:58 -0600",
        "MIME-Version": "1.0",
        "User-Agent": "Mozilla Thunderbird",
        "Content-Language": "en-US",
        "To": "'GCC Patches' <gcc-patches@gcc.gnu.org>",
        "From": "Jeffrey Law <jeffrey.law@oss.qualcomm.com>",
        "Subject": "[to-be-committed][V3][PR target/121268]",
        "X-Proofpoint-ORIG-GUID": "zNpzMvzCxnwmqJHMoPMaiLmHnrdFewgR",
        "X-Authority-Analysis": "v=2.4 cv=Xba5Co55 c=1 sm=1 tr=0 ts=69ef784e cx=c_pps\n a=kVLUcbK0zfr7ocalXnG1qA==:117 a=asGLMfRmzhnGNxaIYohjRg==:17\n a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22\n a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=r77TgQKjGQsHNAKrUKIA:9\n a=NeGlvrA1Pa8BGdrBpgsA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10\n a=lJZwUOCYSaWFdIi53IMA:9 a=yVOC4zewY2VDDqEJ:21 a=_W_S_7VecoQA:10\n a=lHyQXsNW_jjFoZG7ryoA:9 a=B2y7HmGcmWMA:10 a=vr4QvYf-bLy2KjpDp97w:22",
        "X-Proofpoint-GUID": "zNpzMvzCxnwmqJHMoPMaiLmHnrdFewgR",
        "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwNDI3MDE1NyBTYWx0ZWRfX89jRRKVyeBPT\n UQFuJfXhffFz+OtjLUO2O4GKWUKkr/ggxIbUT0Gl/qi9Ia9fzwlSqrcixGmwuVAXbP5+8AhmJ6M\n uzvXkDjETqb3W6B2nc05HeOozMYXf4xN7S4+QSYuOq244AYz5wTknLQ8LpRzVPGKE9xn0QOcaC1\n 78THksQtjSumluIYTTxWCDx3VT/TV4TWgJQdX61tw+APzOKpoqrrG2sl7DnnV8Nl+ErTzxSTglB\n VjHNJLO+IceSe/8y3PazzwSpyKtgoulKLOHILEvN5ksAlUrPFWlB7jMu2y1p1lgy8/r9b6jo8KY\n w5uwJUN/I8DMMN8Q4mmbOPDufRfV85QXH8xeVA1FzAHLJLQJWjHHxDcDSeWEI9QTDKFSYa0ZKS2\n UTURO/QJCB50iK279tKSESIV/poomdSdv13igHektEkJuMFSYXhKR9PZQNejw450bSTktj0+IkY\n YNEnbHU0aos6cCxOgeA==",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-04-27_04,2026-04-21_02,2025-10-01_01",
        "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n priorityscore=1501 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0\n impostorscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 malwarescore=0\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604270157",
        "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": "One more time!  Same pattern, just context adjustment in the patch.\n\n--\n\n\nSo if we have something like (and (not X) (not Y)) where X or Y is a \nsimple register and the other is possibly more complex, but \nimplementable with a single instruction, we want to split at the the \ncomplex expression. Let's say it's Y above.  We want to generate\n\n(set (temp) (not Y))\n(set (dest) (and (not (X) (temp))\n\nThe most interesting cases for Y exploit the ~x = -x + 1 identity or (x \n& -x) - 1 = (x - 1) & ~x\n\nIf we take two functions from the PR:\n\nunsigned int f1(unsigned int x)\n{\n     return ~(x | -x);\n}\n\nunsigned int f3(unsigned int x)\n{\n     return (x & -x) - 1;\n}\n\nCurrently generates this on rv64:\n\n\nf1:\n         negw    a5,a0\n         or      a0,a5,a0\n         not     a0,a0\n         ret\n\nf3:\n         negw    a5,a0\n         and     a0,a5,a0\n         addiw   a0,a0,-1\n         ret\n\n\nAfter this patch we generate:\n\nf1:\n         addiw   a5,a0,-1\n         andn    a0,a5,a0\n         ret\n\nf3:\n         addiw   a5,a0,-1\n         andn    a0,a5,a0\n         ret\n\nI considered doing these in simplify-rtx.  My biggest worry is \nover-fitting to the way the RISC-V port expresses the \"w\" form \ninstructions.  So I stuck with a target specific solution.\n\n\nIt's just a few 3->2 splitters.   The bulk of the patch has been in my \ntester for a while, but the last pattern is new after I did some \nexperimentation on rv32 to make sure it's generating sensible code too.  \nThe runs in my tester have all been without regressions. Obviously I'll \nbe waiting on the pre-commit CI system to render a verdict.",
    "diff": "diff --git a/gcc/config/riscv/bitmanip.md b/gcc/config/riscv/bitmanip.md\nindex 45881994f3a..1ca9f82b363 100644\n--- a/gcc/config/riscv/bitmanip.md\n+++ b/gcc/config/riscv/bitmanip.md\n@@ -927,7 +927,7 @@ (define_insn \"*bext<mode>\"\n \n ;; We do not define SHIFT_COUNT_TRUNCATED, so we have to have variants\n ;; that mask/extend the count if we want to eliminate those ops\n-;;      \n+;;\n ;; We could (in theory) use GPR for the various modes, but I haven't\n ;; seen those cases appear in practice.  Without a testcase I've\n ;; elected to keep the modes X which is easy to reason about.\n@@ -1368,3 +1368,61 @@ (define_split\n    (set (match_dup 0) (zero_extract:X (match_dup 3)\n \t\t\t\t      (const_int 1)\n \t\t\t\t      (zero_extend:X (match_dup 2))))])\n+\n+;; If we have (and (not X) (not Y)), and we can implement one of those NOT\n+;; expressions as a single insn, then do so as that will allow using andn.\n+;; In this case we exploit ~(-x) == x - 1.  Two versions as we can reverse\n+;; the operands of the AND.\n+(define_split\n+  [(set (match_operand:DI 0 \"register_operand\")\n+\t(and:DI\n+\t  (not:DI\n+\t   (sign_extend:DI (neg:SI (match_operand:SI 1 \"register_operand\"))))\n+\t  (not:DI (match_operand:DI 2 \"register_operand\"))))\n+   (clobber (match_operand:DI 3 \"register_operand\"))]\n+  \"TARGET_64BIT && TARGET_ZBB\"\n+  [(set (match_dup 3) (sign_extend:DI (plus:SI (match_dup 1) (const_int -1))))\n+   (set (match_dup 0) (and:DI (not:DI (match_dup 2)) (match_dup 3)))])\n+\n+(define_split\n+  [(set (match_operand:DI 0 \"register_operand\")\n+\t(and:DI\n+\t  (not:DI (match_operand:DI 1 \"register_operand\"))\n+\t  (not:DI\n+\t   (sign_extend:DI (neg:SI (match_operand:SI 2 \"register_operand\"))))))\n+   (clobber (match_operand:DI 3 \"register_operand\"))]\n+  \"TARGET_64BIT && TARGET_ZBB\"\n+  [(set (match_dup 3) (sign_extend:DI (plus:SI (match_dup 2) (const_int -1))))\n+   (set (match_dup 0) (and:DI (not:DI (match_dup 1)) (match_dup 3)))])\n+\n+;; Another variant, this time exploiting (x & -x) - 1 == (x - 1) & ~x\n+(define_split\n+  [(set (match_operand:DI 0 \"register_operand\")\n+\t(sign_extend:DI\n+\t (plus:SI\n+\t  (subreg:SI (and:DI\n+\t\t      (subreg:DI (neg:SI\n+\t\t\t\t  (match_operand:SI 1 \"register_operand\")) 0)\n+\t\t      (match_operand:DI 2 \"register_operand\")) 0)\n+\t  (const_int -1))))\n+   (clobber (match_operand:DI 3 \"register_operand\"))]\n+  \"(TARGET_64BIT\n+    && TARGET_ZBB\n+    && (REG_P (operands[2]) && SUBREG_P (operands[1])\n+\t ? REGNO (operands[2]) == REGNO (SUBREG_REG (operands[1]))\n+\t : REG_P (operands[1]) && SUBREG_P (operands[2])\n+\t   ? (REGNO (SUBREG_REG (operands[2])) == REGNO (operands[1])) : 0))\"\n+  [(set (match_dup 3) (sign_extend:DI (plus:SI (match_dup 1) (const_int -1))))\n+   (set (match_dup 0) (and:DI (not:DI (match_dup 2)) (match_dup 3)))])\n+\n+;; Another exploiting (x & -x) -1 == (x - 1) & ~x\n+(define_split\n+  [(set (match_operand:X 0 \"register_operand\")\n+\t(plus:X (and:X (neg:X (match_operand:X 1 \"register_operand\"))\n+\t\t       (match_dup 1))\n+\t\t(const_int -1)))\n+   (clobber (match_operand:X 2 \"register_operand\"))]\n+  \"TARGET_ZBB\"\n+  [(set (match_dup 2) (plus:X (match_dup 1) (const_int -1)))\n+   (set (match_dup 0) (and:X (not:X (match_dup 1)) (match_dup 2)))])\n+\ndiff --git a/gcc/testsuite/gcc.target/riscv/pr121268.c b/gcc/testsuite/gcc.target/riscv/pr121268.c\nnew file mode 100644\nindex 00000000000..d79f444d2f8\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/riscv/pr121268.c\n@@ -0,0 +1,39 @@\n+/* { dg-do compile } */\n+/* { dg-additional-options \"-march=rv64gcb_zicond -mabi=lp64d\" { target rv64 } } */\n+/* { dg-additional-options \"-march=rv32gcb_zicond -mabi=ilp32\" { target rv32 } } */\n+/* { dg-skip-if \"\" { *-*-* } { \"-O0\" \"-Og\" } } */\n+\n+#define F1(TYPE, NAME) TYPE f1##NAME (TYPE x) { return ~(x | -x); }\n+#define F2(TYPE, NAME) TYPE f2##NAME (TYPE x) { return ~x & (x - 1); }\n+#define F3(TYPE, NAME) TYPE f3##NAME (TYPE x) { return (x & -x) - 1; }\n+\n+F1 (unsigned char, uc)\n+F1 (unsigned short, us)\n+F1 (unsigned int, ui)\n+F1 (unsigned long, ul)\n+F1 (signed char, sc)\n+F1 (signed short, ss)\n+F1 (signed int, si)\n+F1 (signed long, sl)\n+\n+F2 (unsigned char, uc)\n+F2 (unsigned short, us)\n+F2 (unsigned int, ui)\n+F2 (unsigned long, ul)\n+F2 (signed char, sc)\n+F2 (signed short, ss)\n+F2 (signed int, si)\n+F2 (signed long, sl)\n+\n+F3 (unsigned char, uc)\n+F3 (unsigned short, us)\n+F3 (unsigned int, ui)\n+F3 (unsigned long, ul)\n+F3 (signed char, sc)\n+F3 (signed short, ss)\n+F3 (signed int, si)\n+F3 (signed long, sl)\n+\n+/* We match addi and addiw here on purpose.  */\n+/* { dg-final { scan-assembler-times \"addi\" 24 } } */\n+/* { dg-final { scan-assembler-times \"andn\\t\" 24 } } */\n",
    "prefixes": [
        "to-be-committed",
        "V3",
        "PR",
        "target/121268"
    ]
}