get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2216375,
    "url": "http://patchwork.ozlabs.org/api/patches/2216375/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260326105908.3389883-2-konstantinos.eleftheriou@vrull.eu/",
    "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": "<20260326105908.3389883-2-konstantinos.eleftheriou@vrull.eu>",
    "list_archive_url": null,
    "date": "2026-03-26T10:58:56",
    "name": "[v3,1/2] match.pd: Flatten carry-diamond patterns to straight-line code",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "a6efe8db42a9a11aab33aaee5b9aa563d6125b90",
    "submitter": {
        "id": 89121,
        "url": "http://patchwork.ozlabs.org/api/people/89121/?format=api",
        "name": "Konstantinos Eleftheriou",
        "email": "konstantinos.eleftheriou@vrull.eu"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260326105908.3389883-2-konstantinos.eleftheriou@vrull.eu/mbox/",
    "series": [
        {
            "id": 497569,
            "url": "http://patchwork.ozlabs.org/api/series/497569/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=497569",
            "date": "2026-03-26T10:58:55",
            "name": "Recognize and fold longhand wide-multiplication idioms [PR107090]",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/497569/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2216375/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2216375/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=vrull.eu header.i=@vrull.eu header.a=rsa-sha256\n header.s=google header.b=iwZ/6Bht;\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=pass (2048-bit key,\n unprotected) header.d=vrull.eu header.i=@vrull.eu header.a=rsa-sha256\n header.s=google header.b=iwZ/6Bht",
            "sourceware.org;\n dmarc=none (p=none dis=none) header.from=vrull.eu",
            "sourceware.org; spf=pass smtp.mailfrom=vrull.eu",
            "server2.sourceware.org;\n arc=none smtp.remote-ip=209.85.128.50"
        ],
        "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 4fhLk80dh8z1y1G\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 22:13:35 +1100 (AEDT)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 946C84BA2E1E\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 11:13:33 +0000 (GMT)",
            "from mail-wm1-f50.google.com (mail-wm1-f50.google.com\n [209.85.128.50])\n by sourceware.org (Postfix) with ESMTPS id CDF6A4BA2E12\n for <gcc-patches@gcc.gnu.org>; Thu, 26 Mar 2026 11:11:41 +0000 (GMT)",
            "by mail-wm1-f50.google.com with SMTP id\n 5b1f17b1804b1-4852e9ca034so8436665e9.2\n for <gcc-patches@gcc.gnu.org>; Thu, 26 Mar 2026 04:11:41 -0700 (PDT)",
            "from altra1.sec.univie.ac.at (altra1.sec.univie.ac.at.\n [131.130.126.103]) by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-487209204d5sm19623915e9.5.2026.03.26.04.11.39\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 26 Mar 2026 04:11:40 -0700 (PDT)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org 946C84BA2E1E",
            "OpenDKIM Filter v2.11.0 sourceware.org CDF6A4BA2E12"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org CDF6A4BA2E12",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org CDF6A4BA2E12",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774523502; cv=none;\n b=r+mz3/qUm0sYKpLdeFXr10dkO7Ibsfbkx1ajkWiXIrqirKV3quhokGJ/MeSPvI48yLegu55ZCv14/ENIeEXAUek4h7sVPXgGsZ+sSXacLk/nK3EMAh+tBhzXsznJAlaEQjefS9H6HaTsU0QTtE4nSSwYl9q+0ZEQ2d+vyiNS8x4=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774523502; c=relaxed/simple;\n bh=xx2V+T9eWT5vGAByW3//fo+WS/Ruy91cv6zElvRoh+c=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=G+MHKRzRyzHB/35MwlqP+CHP0IjUt371OtVvsQsSI8IKAaGkPnRYyWX9EslrJxiis/eJbju0aNMBT8KGU9yg5FLM0wCWyWwqETVLgVqeLhPpljMOFt9A6UhxYPoJyFyXs66GYyLzo5iKmYpmnZy56PK74mO4wVnmceH3ok+XqAc=",
        "ARC-Authentication-Results": "i=1; server2.sourceware.org",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=vrull.eu; s=google; t=1774523500; x=1775128300; darn=gcc.gnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=bA9+C+KkTaJRgpy/1h5O1WzdFU0QBaQvKv4VeLd9G/U=;\n b=iwZ/6Bhti6GPvxSljhinsgsIyJHpOexcbR5sL9OVadGa20MjLViwh2WeK8XpD0/xYM\n 7Tt5sTU0uT804SjvM1oC7g9WXNzWTtyX4nH0/FQTBq68eNCKmr9Bml1vEjMKslsNaFhM\n tsWpE2mEttJefkxE2pacLEKAmeYuOVTo/FWFg4g4bAsaMHTJUYU5zM9ChLo4ScPkJ8rT\n hdTeIFixMBiWsV5M5MmT3Qpal09jETI5u6pvZ67UXLU02q7OqvYQlDVN5MsD3ox1BxAo\n KWA/0Y9F2NNlY8L0U11NAuaRrK4dC1707QUGfz2Hfx4SBckyAm/cwb223vRnacE71j3q\n /bDw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774523500; x=1775128300;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=bA9+C+KkTaJRgpy/1h5O1WzdFU0QBaQvKv4VeLd9G/U=;\n b=BcT4CWX9gBL7wMKWMO3JX3fHjizEyliT5OcFoQMsYgyNiY8NqvJE7Os+cHe54ILkDc\n kVQSIRhR/4V75OmEblAfJD4A2A3glL0ubnOEHNVl5xpLTs5248aZvD48FTZCEwDGqTM0\n TXOzn5ti2o8fD6jYJXpVU0ayIkxLXW1qzMXY6BucZkN7waEbXOcl6fXE1pWzgjt2t8Py\n IfkFsAOYXD1nZx10UvbRZnC3lUgLs0HKbD73Cp/zdtwSCVdflkWd6o5qMrVtqrNer+uH\n ugRzVkMa9r0WT6qq8OWHriRKFQeHHmH6WJe8T9nER8H5jkldEoohIvhaGyWaLMHCMytX\n FdoQ==",
        "X-Gm-Message-State": "AOJu0Ywfi7N6iQms/8YBQcojpLuHttGzcwVJSdHIijZ2SNO2wGXfG8lT\n jwVACyKget3J7Y4c9ML+FjRrY/Q5CuavUJ8R2PN22bvKT18xXL11oBNB0U5FuAXCdbsRpYFLkRF\n WaZlbxyM=",
        "X-Gm-Gg": "ATEYQzy1C/abh/WqDrszmc40+pYPyg2X8HOcvjGEZL9DLHe2m4fHcLa1mKITwK7ZyvK\n tIJb6KP2WLCMt0Dh8W5CKELLRp3a0gJ1xeOSVLJgm46HHgfrxLEuqBZSCV0qBN588gYJUSrVDQw\n 9ggUDaS+IQ0i387PBC5D+HnouSRZ9U1FQYQkZVKv+H18z1PHdxIe4nMJ8DH3n1Drh0xUPXh65l4\n e0hukhjbqLOqGfHpl1T/crf5/+waiE5nYHUyPRqD9GnqYxTqHdQ7O6yLoXkHRGcjDiT83E6Kzm2\n oLuk+DQlAnTUMC9YxcTOJp0IpRH+UM/3xlYJfnS3yVM4BsXRbRoOpNeC8cUJD180fQSJYX29gRf\n d3QAQHcS6tTae/sAFNYqSX1ZRz3nIfBcVx3tHqalcmpuWgZInK2PgSnyJpk6sbhIo040j+aUzVq\n r/XZOpuvtLRFMvWbNLeosyZ7LGroxzSZlGBLpU+zSqFOvOljel7iB1y6YMPkPJQYRnJUKbSSp0O\n 2Eq0m8O3SWBtrzgncJn",
        "X-Received": "by 2002:a05:600c:1d15:b0:485:3abe:ab86 with SMTP id\n 5b1f17b1804b1-48715fc3d1dmr108508675e9.4.1774523500396;\n Thu, 26 Mar 2026 04:11:40 -0700 (PDT)",
        "From": "Konstantinos Eleftheriou <konstantinos.eleftheriou@vrull.eu>",
        "To": "gcc-patches@gcc.gnu.org",
        "Cc": "Andrew Pinski <andrew.pinski@oss.qualcomm.com>,\n Philipp Tomsich <philipp.tomsich@vrull.eu>,\n Konstantinos Eleftheriou <konstantinos.eleftheriou@vrull.eu>",
        "Subject": "[PATCH v3 1/2] match.pd: Flatten carry-diamond patterns to\n straight-line code",
        "Date": "Thu, 26 Mar 2026 03:58:56 -0700",
        "Message-ID": "<20260326105908.3389883-2-konstantinos.eleftheriou@vrull.eu>",
        "X-Mailer": "git-send-email 2.52.0",
        "In-Reply-To": "<20260326105908.3389883-1-konstantinos.eleftheriou@vrull.eu>",
        "References": "<20260326105908.3389883-1-konstantinos.eleftheriou@vrull.eu>",
        "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": "Recognize and flatten carry-diamond patterns found in longhand\nmultiplication sequences.  A carry diamond implements unsigned overflow\ndetection with conditional carry propagation:\n\n  sum = a + b;\n  if (addend > sum) result = base + C;\n\nThis is replaced with straight-line code:\n\n  carry = (type)(addend > sum);\n  result = base + (carry << log2(C));\n\nThis eliminates the conditional branch and exposes the carry as a\ncomparison expression, enabling downstream pattern matching (e.g.\nlong-multiplication folding in match.pd which expects the form\n(lshift (convert? (gt ...)) INTEGER_CST)).\n\n(PHI<pow2, 0>) is already handled by the existing match.pd\npattern: a ? powerof2cst : 0 -> a << log2(powerof2cst).\n\nBootstrapped/regtested on AArch64 and x86-64.\n\ngcc/ChangeLog:\n\n\t* match.pd: Add carry-diamond simplification for unsigned\n\toverflow detection with conditional carry propagation.\n\ngcc/testsuite/ChangeLog:\n\n\t* gcc.dg/tree-ssa/forwprop-44.c: New test.\n\t* gcc.dg/tree-ssa/forwprop-45.c: New test.\n\nCo-authored-by: Philipp Tomsich <philipp.tomsich@vrull.eu>\nSigned-off-by: Konstantinos Eleftheriou <konstantinos.eleftheriou@vrull.eu>\n---\n\n(no changes since v1)\n\n gcc/match.pd                                | 20 ++++++++++\n gcc/testsuite/gcc.dg/tree-ssa/forwprop-44.c | 21 ++++++++++\n gcc/testsuite/gcc.dg/tree-ssa/forwprop-45.c | 44 +++++++++++++++++++++\n 3 files changed, 85 insertions(+)\n create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/forwprop-44.c\n create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/forwprop-45.c",
    "diff": "diff --git a/gcc/match.pd b/gcc/match.pd\nindex 1d6428bf7e53..59c3a9f2fe69 100644\n--- a/gcc/match.pd\n+++ b/gcc/match.pd\n@@ -6555,6 +6555,26 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)\n       (lshift (convert (bit_xor (convert:boolean_type_node @0)\n \t\t\t\t{ boolean_true_node; })) { shift; })))))))\n \n+/* Carry diamond: (a > a+b) ? (base + pow2) : base\n+   -> base + ((type)(a > a+b) << log2(pow2))\n+   This flattens unsigned overflow detection with conditional carry\n+   propagation to straight-line code, enabling downstream long-multiply\n+   pattern matching.  */\n+(for cmp (gt lt)\n+ (simplify\n+  (cond (cmp:c @0 (plus:c @0 @1)) (plus:c @2 INTEGER_CST@3) @2)\n+  (if (INTEGRAL_TYPE_P (type)\n+       && TYPE_UNSIGNED (type)\n+       && integer_pow2p (@3))\n+   (with {\n+     tree shift = build_int_cst (integer_type_node, tree_log2 (@3));\n+    }\n+    (plus @2\n+\t  (lshift\n+\t    (convert (convert:boolean_type_node\n+\t      (cmp @0 (plus @0 @1))))\n+\t      { shift; }))))))\n+\n /* (a > 1) ? 0 : (cast)a is the same as (cast)(a == 1)\n    for unsigned types. */\n (simplify\ndiff --git a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-44.c b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-44.c\nnew file mode 100644\nindex 000000000000..432bdda60e5e\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-44.c\n@@ -0,0 +1,21 @@\n+/* { dg-do compile } */\n+/* { dg-options \"-O2 -fdump-tree-phiopt2\" } */\n+\n+/* Test that phiopt flattens a simple carry diamond:\n+     sum = a + b;\n+     if (b > sum) result = base + 1;\n+   The conditional branch is replaced with straight-line code:\n+     carry = (type)(b > sum); result = base + carry;  */\n+\n+unsigned long\n+test_carry_diamond (unsigned long a, unsigned long b,\n+\t\t    unsigned long base)\n+{\n+  unsigned long sum = a + b;\n+  unsigned long result = base;\n+  if (b > sum)\n+    result = base + 1;\n+  return result;\n+}\n+\n+/* { dg-final { scan-tree-dump-not \"goto\" \"phiopt2\" } } */\ndiff --git a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-45.c b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-45.c\nnew file mode 100644\nindex 000000000000..602c698e817a\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-45.c\n@@ -0,0 +1,44 @@\n+/* { dg-do compile } */\n+/* { dg-options \"-O2 -fdump-tree-phiopt2\" } */\n+/* { dg-require-effective-target lp64 } */\n+\n+/* Test that phiopt flattens carry diamonds with a power-of-2 carry\n+   constant.  The conditional branch:\n+     sum = a + b; if (b > sum) result = base + (1UL << 32);\n+   is replaced with:\n+     carry = (type)(b > sum); result = base + (carry << 32);\n+   This form is what match.pd's mul_carry_cross_sum pattern expects.  */\n+\n+unsigned long\n+test_carry_diamond_shift (unsigned long a, unsigned long b,\n+\t\t\t  unsigned long base)\n+{\n+  unsigned long sum = a + b;\n+  unsigned long result = base;\n+  if (b > sum)\n+    result = base + (1UL << 32);\n+  return result;\n+}\n+\n+/* Two carry diamonds in sequence, as in long-multiply carry chains:\n+   one with a shifted constant and one with a plain +1.  */\n+\n+unsigned long\n+test_carry_diamond_chain (unsigned long a, unsigned long b,\n+\t\t\t  unsigned long c, unsigned long d,\n+\t\t\t  unsigned long base)\n+{\n+  unsigned long sum1 = a + b;\n+  unsigned long r1 = base;\n+  if (b > sum1)\n+    r1 = base + (1UL << 32);\n+\n+  unsigned long sum2 = c + d;\n+  unsigned long r2 = r1;\n+  if (d > sum2)\n+    r2 = r1 + 1;\n+\n+  return r2;\n+}\n+\n+/* { dg-final { scan-tree-dump-not \"goto\" \"phiopt2\" } } */\n",
    "prefixes": [
        "v3",
        "1/2"
    ]
}