get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2224782,
    "url": "http://patchwork.ozlabs.org/api/patches/2224782/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/87bjfgqodm.fsf@googlemail.com/",
    "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": "<87bjfgqodm.fsf@googlemail.com>",
    "list_archive_url": null,
    "date": "2026-04-18T15:28:21",
    "name": "cse: Validate subreg replacements [PR124643]",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "c7b524a1c93cf0638e280004b5fda9bbb629bf02",
    "submitter": {
        "id": 4363,
        "url": "http://patchwork.ozlabs.org/api/people/4363/?format=api",
        "name": "Richard Sandiford",
        "email": "rdsandiford@googlemail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/87bjfgqodm.fsf@googlemail.com/mbox/",
    "series": [
        {
            "id": 500449,
            "url": "http://patchwork.ozlabs.org/api/series/500449/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500449",
            "date": "2026-04-18T15:28:21",
            "name": "cse: Validate subreg replacements [PR124643]",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/500449/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2224782/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2224782/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 (2048-bit key;\n unprotected) header.d=googlemail.com header.i=@googlemail.com\n header.a=rsa-sha256 header.s=20251104 header.b=JIR8cm2N;\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 (2048-bit key,\n unprotected) header.d=googlemail.com header.i=@googlemail.com\n header.a=rsa-sha256 header.s=20251104 header.b=JIR8cm2N",
            "sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=googlemail.com",
            "sourceware.org; spf=pass smtp.mailfrom=googlemail.com",
            "server2.sourceware.org;\n arc=none smtp.remote-ip=209.85.128.42"
        ],
        "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 4fybJ54dzZz1yGt\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 19 Apr 2026 01:28:53 +1000 (AEST)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id AB9C64AA54C3\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 18 Apr 2026 15:28:51 +0000 (GMT)",
            "from mail-wm1-f42.google.com (mail-wm1-f42.google.com\n [209.85.128.42])\n by sourceware.org (Postfix) with ESMTPS id 8AEAC4BA2E0F\n for <gcc-patches@gcc.gnu.org>; Sat, 18 Apr 2026 15:28:24 +0000 (GMT)",
            "by mail-wm1-f42.google.com with SMTP id\n 5b1f17b1804b1-4887fd35e60so10436095e9.2\n for <gcc-patches@gcc.gnu.org>; Sat, 18 Apr 2026 08:28:24 -0700 (PDT)",
            "from localhost ([103.214.45.63])\n by smtp.googlemail.com with ESMTPSA id\n 5b1f17b1804b1-488fc18bccfsm124085775e9.8.2026.04.18.08.28.22\n for <gcc-patches@gcc.gnu.org>\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sat, 18 Apr 2026 08:28:22 -0700 (PDT)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org AB9C64AA54C3",
            "OpenDKIM Filter v2.11.0 sourceware.org 8AEAC4BA2E0F"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 8AEAC4BA2E0F",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 8AEAC4BA2E0F",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776526104; cv=none;\n b=AIW1Xxu7XyyTxujPssef+bIq27CuyzbAZepDBw++WgWa7fe+LXKyKFiJn2VOQcM6uzSrIXjbCcmzgmOJ2AlExwQnsNUiv18iShOE0BAsYG5HvPj8VOTqEzqny7U9yMh2malDeWF774D6UpyierSvyK3Uy/uriPNGNMxF0bKbC80=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776526104; c=relaxed/simple;\n bh=MaymobQFDW5BoVOqxfKQFetvJfQtvXnpZeRxeWXRQL8=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=D5027ExeFy2rOV6XPDDak6T/F+VtgTsDOSqtX6UCqjZ3N+Mx23xN1M2C2/cXNU0fIQ7FzF7Mh6XkrBZPzmsRuaF3mOBci8soWOmWD6ymb1zdkNq/Vba7GByOqgJZa1yonzg21SnKNWfGGnleFymbFkgx7ErOt///eUQHJPGjE0A=",
        "ARC-Authentication-Results": "i=1; server2.sourceware.org",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=googlemail.com; s=20251104; t=1776526103; x=1777130903; darn=gcc.gnu.org;\n h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to\n :from:from:to:cc:subject:date:message-id:reply-to;\n bh=Jp01TeK+3pyfrfw+PrW0v4rEnu8lHa6Tg53Xfr7JwnQ=;\n b=JIR8cm2NW5jwHqmbhZkh8ueMOd2Nq6ZFZoeo0hAqaWCQoGfKlyi5AlPtaMXE/h/+5N\n HjvMcTIG+xS77VGvMLejHuKJFLr52uRxr/NJyFDBnmZgaZs2NoAPG71u1cEoH+svbn2R\n UlBnIOmkZzxXmarsT22FlvOivZIFqkzj2oZyNrUgvOWjrmCWWuzVUxCsEK4j8BBMnXzR\n i2boWHpt+exaG6/O96rP+Rwcc+UZu/4kg/vLW0NaJodO11MlWaI5f66tJny4sZNa6K5F\n Hta8dXLH4VfvBpuVkJSzD7XaBmFBdwAsJ8l6qZNEgxan3RrNmDstJtvroRUrH4gTX9U5\n Ohkw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776526103; x=1777130903;\n h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to\n :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=Jp01TeK+3pyfrfw+PrW0v4rEnu8lHa6Tg53Xfr7JwnQ=;\n b=lB6RyNtvO5Ns5NEsLpPm4PmVZvyssbpwqRzli6rSS2QpLVMIAeu9MtaDc8LSY/dC4G\n 059B1T5bpjV8jJomrg2xCkup/A2WPf8J15fYDUYxO2ioHUIb2bTjVIgLlEsjS0td71zE\n uCDRSYNPChc/0J3W0o/taYX3CpxyDpnjAuruw5YRyeS6/0b4RIcxAb/F3CW2+/NPMycr\n Z13BWAqYfbA/zBHxFJd+heBtZXyuK99eRhi1y3IqfZMkiPHrv+Ftq+iw4VP1Ejm2UEAY\n ZvwHVChSYCf1P3B58ZbYCNT3XHz7IEB9mE9EoTLgCqKU3B75eikyfNdj+9w7Qx8DYFNn\n VXPw==",
        "X-Gm-Message-State": "AOJu0YwsoP7fL9AvvyYB18K0rv20IzAR5xwHVU9c1uw++MfVf38jXfWs\n nPUxVRr8tNuNElnEPYrAUac84a4SCM9UoKBmSz9dPyxte7DuOaa+Zr2Hx9+IHg==",
        "X-Gm-Gg": "AeBDievEdpTixqHIKF4en5zDGtKnjGA8COK6fPgawWinAxHQN7V/1rkKi36582bsGMm\n 6miBX2uzQUGg4q0FcgKutQK8AjngUZoTmnb0ztgnCb3uMUOq0TTLsffBrY3MWIY7pwotuUwrRCV\n AwABoyhZ7Wd9dOQnqymVa86nzIfa7jWkNV7BXJ+0pTXHV0XMtsm9BnRoyQD+62AAiLnLbJ8RhoT\n z/5K3DqxENtW3eo0Fd2uCHivWDmjRjP5kBj9x0bVzOLwkRKhm55nqMSG+2j3+pknJgV0KUz5iPV\n 1dklJx2xZUva8vn52tj9ItupCMVWArULByzdBxT2MD5cBd0lJmWgIDvguXypNQQ1S7IuAOTVIYm\n VujXCOIvR5Fcz478CePVPHnaqtr+lPDPkbgWAeysf6KXw11gZS9RbjpiAMsq4xk8BYyicA1Wl11\n oWjxF8lADsGCzu0H31zOqAVUOxRqKTwqa5ae4T/WU=",
        "X-Received": "by 2002:a05:600d:8451:b0:487:20ee:bef6 with SMTP id\n 5b1f17b1804b1-488fb745684mr85397925e9.11.1776526103331;\n Sat, 18 Apr 2026 08:28:23 -0700 (PDT)",
        "From": "Richard Sandiford <rdsandiford@googlemail.com>",
        "To": "gcc-patches@gcc.gnu.org",
        "Mail-Followup-To": "gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com",
        "Subject": "[PATCH] cse: Validate subreg replacements [PR124643]",
        "Date": "Sat, 18 Apr 2026 16:28:21 +0100",
        "Message-ID": "<87bjfgqodm.fsf@googlemail.com>",
        "User-Agent": "Gnus/5.13 (Gnus v5.13)",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "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 PR is about an ICE on sh caused by an \"invalid\" subreg.\ncse replaced a pseudo register with the hard T register within:\n\n  (zero_extend:SI (subreg:QI (reg:SI pseudo) 3))\n\nSince this is a register-for-register replacement, cse just relied on\nrecog to reject anything that wasn't valid.\n\nHowever, if validate_subreg had been asked, it would have said that:\n\n  (subreg:QI (reg:SI T) 3)\n\nis not valid.  This means that even simplify_gen_subreg would have\nrefused to generate it.\n\nIn that sense, cse should not even be trying to match this replacement.\nIt's not recog's job to reject all invalid rtl.  recog is just supposed\nto say whether the machine supports a given piece of valid rtl.\n\nIn this particular case, the sh port does specifically match:\n\n  (zero_extend:SI (subreg:QI (reg:SI T) 3))\n\neven though, by forbidding T from having QImode, the port also\neffectively forbids the subreg.  See the discussion in the PR trail\nabout that.  But I think the point still stands that cse should verify\nthe subregs that it creates.  It should also try to simplify them down\nto hard registers where possible.\n\nI suppose a more complete fix would be to rewrite canon_reg to use a\nhelper that recursively replaces and simplifies, but that seems somewhat\ndangerous at this stage.  The scope for non-subreg simplification should\nalso be pretty limited in practice.\n\nTested on x86_64-linux-gnu, powerpc64le-linux-gnu and aarch64-linux-gnu.\nOK to install?\n\nRichard\n\n\ngcc/\n\tPR rtl-optimization/124643\n\t* cse.cc (canon_reg): Handle and canonicalize subregs.\n\ngcc/testsuite/\n\tPR rtl-optimization/124643\n\t* gcc.c-torture/compile/pr124643.c: New test.\n---\n gcc/cse.cc                                     | 18 ++++++++++++++++++\n gcc/testsuite/gcc.c-torture/compile/pr124643.c |  8 ++++++++\n 2 files changed, 26 insertions(+)\n create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr124643.c",
    "diff": "diff --git a/gcc/cse.cc b/gcc/cse.cc\nindex e5fa88f9de5..25b2bf500a9 100644\n--- a/gcc/cse.cc\n+++ b/gcc/cse.cc\n@@ -2847,6 +2847,24 @@ canon_reg (rtx x, rtx_insn *insn)\n     case ADDR_DIFF_VEC:\n       return x;\n \n+    case SUBREG:\n+      {\n+\trtx inner = canon_reg (SUBREG_REG (x), insn);\n+\tif (inner != SUBREG_REG (x))\n+\t  {\n+\t    rtx newx = simplify_subreg (GET_MODE (x), inner,\n+\t\t\t\t\tGET_MODE (SUBREG_REG (x)),\n+\t\t\t\t\tSUBREG_BYTE (x));\n+\t    if (newx)\n+\t      return newx;\n+\n+\t    if (validate_subreg (GET_MODE (x), GET_MODE (inner),\n+\t\t\t\t inner, SUBREG_BYTE (x)))\n+\t      validate_change (insn, &SUBREG_REG (x), inner, 1);\n+\t  }\n+\treturn x;\n+      }\n+\n     case REG:\n       {\n \tint first;\ndiff --git a/gcc/testsuite/gcc.c-torture/compile/pr124643.c b/gcc/testsuite/gcc.c-torture/compile/pr124643.c\nnew file mode 100644\nindex 00000000000..f3f12bef11e\n--- /dev/null\n+++ b/gcc/testsuite/gcc.c-torture/compile/pr124643.c\n@@ -0,0 +1,8 @@\n+int a;\n+char *b;\n+void c(int a) {\n+  int d = (a & 2) != 0 && a & 1;\n+  for (;;)\n+    if (a)\n+      b[1 ^ d] = b[d];\n+}\n",
    "prefixes": []
}