get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2217993,
    "url": "http://patchwork.ozlabs.org/api/patches/2217993/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260331080542.97649-1-garthlei@linux.alibaba.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": "<20260331080542.97649-1-garthlei@linux.alibaba.com>",
    "list_archive_url": null,
    "date": "2026-03-31T08:05:42",
    "name": "simplify-rtx: Simplify (eq/ne (and/ior x C1) C2) in special cases",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "4b6f60930adca9b2f53a44cb25c655c6f5fce22c",
    "submitter": {
        "id": 89310,
        "url": "http://patchwork.ozlabs.org/api/people/89310/?format=api",
        "name": "Bohan Lei",
        "email": "garthlei@linux.alibaba.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260331080542.97649-1-garthlei@linux.alibaba.com/mbox/",
    "series": [
        {
            "id": 498140,
            "url": "http://patchwork.ozlabs.org/api/series/498140/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=498140",
            "date": "2026-03-31T08:05:42",
            "name": "simplify-rtx: Simplify (eq/ne (and/ior x C1) C2) in special cases",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/498140/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2217993/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2217993/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=linux.alibaba.com header.i=@linux.alibaba.com\n header.a=rsa-sha256 header.s=default header.b=i1SabHfh;\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=linux.alibaba.com header.i=@linux.alibaba.com\n header.a=rsa-sha256 header.s=default header.b=i1SabHfh",
            "sourceware.org; dmarc=pass (p=none dis=none)\n header.from=linux.alibaba.com",
            "sourceware.org;\n spf=pass smtp.mailfrom=linux.alibaba.com",
            "server2.sourceware.org;\n arc=none smtp.remote-ip=115.124.30.98"
        ],
        "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 4flLLm0Qjqz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 19:07:12 +1100 (AEDT)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id C3A0B4B7A1D2\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 08:07:09 +0000 (GMT)",
            "from out30-98.freemail.mail.aliyun.com\n (out30-98.freemail.mail.aliyun.com [115.124.30.98])\n by sourceware.org (Postfix) with ESMTPS id 462EF4BAD16D\n for <gcc-patches@gcc.gnu.org>; Tue, 31 Mar 2026 08:05:57 +0000 (GMT)",
            "from localhost(mailfrom:garthlei@linux.alibaba.com\n fp:SMTPD_---0X03ffoG_1774944345 cluster:ay36) by smtp.aliyun-inc.com;\n Tue, 31 Mar 2026 16:05:52 +0800"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org C3A0B4B7A1D2",
            "OpenDKIM Filter v2.11.0 sourceware.org 462EF4BAD16D"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 462EF4BAD16D",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 462EF4BAD16D",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774944359; cv=none;\n b=b16wVzrtN4yg0U/I2fO+ZjIfaTpypn4vPB9kikyjpBCMVW0rhR6Nn/DcONmUkny2/1XIL69s6Kk5Lor4NZnfwsDqsE6b0KNvJe9xV3TDIF+Gm5ioeBMYF6FOu+E0CjO6ka2QgJOjJOXbJWNPnQD1Csg2pTSmEONT/KNX7wSwBeQ=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774944359; c=relaxed/simple;\n bh=XQHZYRCsBcw02PtoDjgaWymA5B8CKR7XETo6FEACTLY=;\n h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version;\n b=dLeOiQsmbZeRKMYjykIXgXzCGfYRV5FcNmKxwTcx6yYsx0qyarSyqOELbpMZMKMMQCTK29CtVPUmq1iTlWFUmJJ1Bqp2iQCD4ZXn4yZzfDtQqeZjnACGA8mwuFGw+hBSEGk93g/K5Dg3sjiKcpYv+AoV1YVaAB4mMoJT5dwF4Zs=",
        "ARC-Authentication-Results": "i=1; server2.sourceware.org",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linux.alibaba.com; s=default;\n t=1774944354; h=From:To:Subject:Date:Message-Id:MIME-Version;\n bh=rgNayV1X5j0fvRO56i4RWGbRW6/Yig/+L3gPugOM+h4=;\n b=i1SabHfhb64ctYO3GCyRAGkk/ppvQkHoiuds0W4C/aLQXQejBnid0xoJAr6bWrARNq4XLcmLw1p+uR0NCQBmMb0az9QKkeGeR7w9bCHeNw5adONDmTCcTi6/z6qfnlI24WSyrZTQhIIsGetJ1xhJSMUd1r+F4SF93dD22GRf9Tw=",
        "X-Alimail-AntiSpam": "AC=PASS; BC=-1|-1; BR=01201311R341e4; CH=green;\n DM=||false|;\n DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=maildocker-contentspam033037009110;\n MF=garthlei@linux.alibaba.com; NM=1; PH=DS; RN=4; SR=0;\n TI=SMTPD_---0X03ffoG_1774944345;",
        "From": "Bohan Lei <garthlei@linux.alibaba.com>",
        "To": "gcc-patches@gcc.gnu.org",
        "Cc": "jeffrey.law@oss.qualcomm.com, philipp.tomsich@vrull.eu,\n Bohan Lei <garthlei@linux.alibaba.com>",
        "Subject": "[PATCH] simplify-rtx: Simplify (eq/ne (and/ior x C1) C2) in special\n cases",
        "Date": "Tue, 31 Mar 2026 16:05:42 +0800",
        "Message-Id": "<20260331080542.97649-1-garthlei@linux.alibaba.com>",
        "X-Mailer": "git-send-email 2.39.3 (Apple Git-146)",
        "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": "This patch adds missing simplifications for (eq/ne (and/ior x C1) C2) in\nspecial cases.  In the AND case, when (and C1 C2) is not equal to C1,\nsome bits set in C2 are not set in C1, and thus (eq (and x C1) C2) can\nnever be true.  The OR case is similar when (and C1 C2) is not equal to\nC2.\n\nThe patch is meant to fix an ICE on RISC-V.  In a former patch, I tried\nto change the insn condition directly, but Jeff pointed out that it was\nmore reasonable to optimize it out before the split.  As was suggested\nby Jeff, this patch tries to simplify the expression in\nsimplify_relational_operation_1.\n\nThe URL for the former patch:\nhttps://patchwork.sourceware.org/project/gcc/patch/20251229024238.15044-1-garthlei@linux.alibaba.com/\n\ngcc/ChangeLog:\n\n\t* simplify-rtx.cc (simplify_context::simplify_relational_operation_1):\nAdd simplifications for (eq/ne (and/ior x C1) C2) in special cases.\n\ngcc/testsuite/ChangeLog:\n\n\t* gcc.target/riscv/zbs-if_then_else-02.c: New test.\n---\n gcc/simplify-rtx.cc                           | 30 +++++++++++++++++\n .../gcc.target/riscv/zbs-if_then_else-02.c    | 32 +++++++++++++++++++\n 2 files changed, 62 insertions(+)\n create mode 100644 gcc/testsuite/gcc.target/riscv/zbs-if_then_else-02.c",
    "diff": "diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc\nindex 50fc51152ca..e2d5abf394f 100644\n--- a/gcc/simplify-rtx.cc\n+++ b/gcc/simplify-rtx.cc\n@@ -6731,6 +6731,36 @@ simplify_context::simplify_relational_operation_1 (rtx_code code,\n \t}\n     }\n \n+  /* (eq/ne (and x C1) C2) simplifies to 0/1 if (and C1 C2) is not equal\n+     to C1.  Bits that are zero in C1 will be zero in the result, so if\n+     C1 has any bits set that C2 doesn't have, the comparison can never\n+     be true.  */\n+  if ((code == EQ || code == NE)\n+      && op0code == AND\n+      && CONST_SCALAR_INT_P (op1)\n+      && CONST_SCALAR_INT_P (XEXP (op0, 1)))\n+    {\n+      HOST_WIDE_INT c1 = INTVAL (XEXP (op0, 1));\n+      HOST_WIDE_INT c2 = INTVAL (op1);\n+      if ((c1 & c2) != c1)\n+\treturn code == EQ ? const0_rtx : const_true_rtx;\n+    }\n+\n+  /* (eq/ne (ior x C1) C2) simplifies to 0/1 if (and C1 C2) is not equal\n+     to C2.  Bits that are one in C1 will be one in the result, so if C2\n+     has any bits clear that C1 has set, the comparison can never be\n+     true.  */\n+  if ((code == EQ || code == NE)\n+      && op0code == IOR\n+      && CONST_SCALAR_INT_P (op1)\n+      && CONST_SCALAR_INT_P (XEXP (op0, 1)))\n+    {\n+      HOST_WIDE_INT c1 = INTVAL (XEXP (op0, 1));\n+      HOST_WIDE_INT c2 = INTVAL (op1);\n+      if ((c1 & c2) != c2)\n+\treturn code == EQ ? const0_rtx : const_true_rtx;\n+    }\n+\n   /* (eq/ne (bswap x) C1) simplifies to (eq/ne x C2) with C2 swapped.  */\n   if ((code == EQ || code == NE)\n       && GET_CODE (op0) == BSWAP\ndiff --git a/gcc/testsuite/gcc.target/riscv/zbs-if_then_else-02.c b/gcc/testsuite/gcc.target/riscv/zbs-if_then_else-02.c\nnew file mode 100644\nindex 00000000000..3393bea8898\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/riscv/zbs-if_then_else-02.c\n@@ -0,0 +1,32 @@\n+/* { dg-do link  { target { rv64 } } } */\n+/* { dg-options \"-march=rv64gc_zbb_zbs -mabi=lp64d -flto\" } */\n+/* { dg-skip-if \"\" { *-*-* } { \"-O0\" \"-Og\" \"-O1\" } } */\n+\n+struct S {\n+  int a;\n+  char b;\n+  int c;\n+} s;\n+\n+const signed char c = -37;\n+int d;\n+struct S v1[] = {{0, 8}, 0, 0, -108976}, v2[] = {{}, 0, 0, 2804};\n+int a;\n+struct S v3[3];\n+int *p = &a;\n+\n+void foo() {\n+  int a;\n+  if (a)\n+    ;\n+  else if (v1[0].b)\n+    s.a = 0;\n+  else\n+    d = 0;\n+  if (*p)\n+    if (v3[1].c)\n+      if (1 ^ (d & c & v2[1].c & ~v1[1].c | s.a))\n+        v3[2].c = 0;\n+}\n+\n+int main() { foo(); }\n",
    "prefixes": []
}