get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2223959,
    "url": "http://patchwork.ozlabs.org/api/patches/2223959/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260416122941.286122-1-daniel.barboza@oss.qualcomm.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": "<20260416122941.286122-1-daniel.barboza@oss.qualcomm.com>",
    "list_archive_url": null,
    "date": "2026-04-16T12:29:41",
    "name": "[v3] match.pd: right shift compare canonicalization [PR124808]",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "bb57f4ce57086a37fb3cf869798dbc377ad4f14b",
    "submitter": {
        "id": 92288,
        "url": "http://patchwork.ozlabs.org/api/people/92288/?format=api",
        "name": "Daniel Barboza",
        "email": "daniel.barboza@oss.qualcomm.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260416122941.286122-1-daniel.barboza@oss.qualcomm.com/mbox/",
    "series": [
        {
            "id": 500152,
            "url": "http://patchwork.ozlabs.org/api/series/500152/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500152",
            "date": "2026-04-16T12:29:41",
            "name": "[v3] match.pd: right shift compare canonicalization [PR124808]",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/500152/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2223959/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2223959/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=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=LXO2aa40;\n\tdkim=pass (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=ZxmM4BSm;\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=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=LXO2aa40;\n\tdkim=pass (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=ZxmM4BSm",
            "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\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 4fxHTK1C25z1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 22:32:19 +1000 (AEST)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id C2C3B4BA9009\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 12:32:17 +0000 (GMT)",
            "from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com\n [205.220.180.131])\n by sourceware.org (Postfix) with ESMTPS id EC6124BA9004\n for <gcc-patches@gcc.gnu.org>; Thu, 16 Apr 2026 12:29:48 +0000 (GMT)",
            "from pps.filterd (m0279869.ppops.net [127.0.0.1])\n by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 63G6ohU3218870\n for <gcc-patches@gcc.gnu.org>; Thu, 16 Apr 2026 12:29:48 GMT",
            "from mail-qt1-f198.google.com (mail-qt1-f198.google.com\n [209.85.160.198])\n by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4djtuyh66t-1\n (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n for <gcc-patches@gcc.gnu.org>; Thu, 16 Apr 2026 12:29:48 +0000 (GMT)",
            "by mail-qt1-f198.google.com with SMTP id\n d75a77b69052e-50b52a2d70cso134902911cf.3\n for <gcc-patches@gcc.gnu.org>; Thu, 16 Apr 2026 05:29:47 -0700 (PDT)",
            "from QCOM-UWl2o8bcGT.qualcomm.com (189-68-248-239.dsl.telesp.net.br.\n [189.68.248.239]) by smtp.gmail.com with ESMTPSA id\n 6a1803df08f44-8ae6cb9eb92sm35428746d6.24.2026.04.16.05.29.44\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 16 Apr 2026 05:29:45 -0700 (PDT)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org C2C3B4BA9009",
            "OpenDKIM Filter v2.11.0 sourceware.org EC6124BA9004"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org EC6124BA9004",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org EC6124BA9004",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776342589; cv=none;\n b=OEbIHgFWilo6hAOGWSNiSPJa3NKd1Jnhv+Y6rHHtAu+HyIp1KNmRZqgZ0aU/oFqWj5LVLZHRrqiFhJfa6JRTJqNL/LWn/3SYh2weVmflNtFnZmJp0AXAbcGVLdhmm3K5IsAAXNJBsydi7yaUuXPFnNxaHgtrdD97m8xqyYiGNzg=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776342589; c=relaxed/simple;\n bh=njnsDDlpd+B00Smq8q8Juv+oBHzBn+0/tnKYkdYaT7M=;\n h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID:\n MIME-Version;\n b=RQcCikFFki/2yhToTDTnzNGngG0/C+wSfjweB1Ue4Dzsl1hpXQKq9Vs9ByVqBNYwvKjw0moubCD18vV/fKNyZdh6VvBJ6/t/xkGUUh8y8VzeJScY8W7lNcyapVYaefsvTr8FehZ5dqRHPj1QeEtGVCINoqhcPI/CMae6m0aAYWA=",
        "ARC-Authentication-Results": "i=1; server2.sourceware.org",
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=\n cc:content-transfer-encoding:date:from:message-id:mime-version\n :subject:to; s=qcppdkim1; bh=DZ/DgqIrDHrVk0ttyamUsj0bgqEe3Gbnsf9\n 779h7cII=; b=LXO2aa40SsctJgnepqLQq52YDwKqTh7dofu5p0+hSgn47IQwxp7\n j3vpypHzC24zxXPXygcd/YCgjlMVMH9Wz4y/2Gk14XiHgCaeV0ngF3IyavMgh7eT\n BNFO9hPy4yJ5iHr8DXq9TSfTKJ1g418qS+SpzKy2Rgdq+tWloJxu9CltY1qvUIwu\n 8PU/F+Q3o6tPJFgzhlwC9hm9IlGTRM7P1ku2x34EguZw785DhB4NhRNjGvtfK58S\n hyDCFBMMfIIearNSWyN5YhNUQVVG1RpOVgVbjxCGUxRKGtSgp1fdEaO3TTzQWzI7\n ZsZAPadVqppdx5A1NiPRbt5qbw4CxV9/Jvg==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=oss.qualcomm.com; s=google; t=1776342587; x=1776947387; darn=gcc.gnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=DZ/DgqIrDHrVk0ttyamUsj0bgqEe3Gbnsf9779h7cII=;\n b=ZxmM4BSmHlesTKCr5ewj0Bxr4zyFTV1dJYoK3kMXYoP/YhkO/LOG7YNcuoChu38u9a\n qjaEVLmN7Ok6A31M0mrUbWW7dqk5el0bhqgBD/Ai44jBI3mhixvexyKiXkTj1yHPzqds\n Lvjn5umZepiqiLAJXQp5J9jWMUb1DJPP3vqBLZIcwPLQC8u4fy/QFlXOEk4vEu2WpK8H\n nELu0phifi87G+adUxs15w3Je8XydOkvuXYQCd2QEX1QqUINjCJCxef+dXktZCsfIHx2\n Hz8ADvKFR7giJT8MSQ0a0wVIeAIAcwqoxzUNE0yOfsNIGWdC1m892Y0GzvH0JbLc111A\n cSbQ=="
        ],
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776342587; x=1776947387;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=DZ/DgqIrDHrVk0ttyamUsj0bgqEe3Gbnsf9779h7cII=;\n b=JMlVEdzigcJgPL2zJoO3Ul1tfh5tg89KozpXSfSq19y0Api2e0FHpIuXnRU4eTeur1\n eMf7qnGHmQt15/7qRLFEBfL34vAU/I/7vtraDJZU1j2YQTg3f+TCMOjEUEnX7EkqE+Zw\n bMYjhlu2pFEaQ3pL7wzeLoqlVQ/wvwTvdFkbsKVF8zAnbcpirsYFAKo8BobWXyOkTt89\n EFWmaZ0XEZgdUAel/NVBtFGyoQYuiM2n48eP88+sCGDI8+p0ax+Tp7oS75qHKWOXDGKm\n uLfo6gJYxxtVpPWJ7uvFyv65sMigibDvvlwK/V0e0gPUzRDDoen+Tw9jTUK7fFgaIT/I\n asJg==",
        "X-Gm-Message-State": "AOJu0YyuNH2XtN21RuY0I9Ydx1rch/yPI02KJcmG98mQXa0Ziswb+DjT\n 6/TotGvFUIIqzKLxIj/YLCIBDBrveLhKaq5g3zxpyf8zNElrysqk8VupnZtH0Yervhr5bon47AB\n +/MBOFkQ/czH02llQPth89KFMvvgvSSNhVLUGAfwuZf/52Ixi2PNJCLWLYz14qPHJk+Rg",
        "X-Gm-Gg": "AeBDieuVLO6Gnp3gPxeOXrxg3A+ye6ujJl65jjwISPbTPbgdvGUjpVwMoSomaOYM6ev\n kJ9q+Ax//Wl4oG/Jn6vys9ctBtv887VKSp4w+WrlbsgX8VUgUSWIbo3aW+dslbKnWQCs66n5Box\n wT6zWePxzvbSsz2DJ+nBfqzrk/KXL4bk2ik9xbdP2soRfiUQAT6aA0HNwewC+9ke68zW37CwpdU\n RAjwRX0vRUYLfA5S8bA36x01kQk7Kmr8ln+xNR9U11R6KE8Pw+oW+x9d/qhkY/1raqZWK6C3Pwc\n Gb5ZA5r6NGVxl0aSsQ+DWIBck7JbBwzEv0KMvr8sf/UkL0zoLIcZWWlzvsWHwvBqF92LzsLewMZ\n nmaxIHflk4jA/lP/SphtkJdF5raqXMvQKl/LkwCc8mogfwWSxUDuvQESw5iuLDfkeSgHL7JWr85\n WCy8L2u0ZRm+gEtF1a+rCAHjaWiqgl",
        "X-Received": [
            "by 2002:a05:622a:2588:b0:50d:e356:5d7f with SMTP id\n d75a77b69052e-50de35667dfmr338132841cf.46.1776342586732;\n Thu, 16 Apr 2026 05:29:46 -0700 (PDT)",
            "by 2002:a05:622a:2588:b0:50d:e356:5d7f with SMTP id\n d75a77b69052e-50de35667dfmr338132191cf.46.1776342586117;\n Thu, 16 Apr 2026 05:29:46 -0700 (PDT)"
        ],
        "From": "Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>",
        "To": "gcc-patches@gcc.gnu.org",
        "Cc": "jeffrey.law@oss.qualcomm.com, andrew.pinski@oss.qualcomm.com,\n Daniel Barboza <daniel.barboza@oss.qualcomm.com>",
        "Subject": "[PATCH v3] match.pd: right shift compare canonicalization [PR124808]",
        "Date": "Thu, 16 Apr 2026 09:29:41 -0300",
        "Message-ID": "<20260416122941.286122-1-daniel.barboza@oss.qualcomm.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwNDE2MDExOSBTYWx0ZWRfX0VxSzUfGLfV1\n M6CCMomEFvytcexazXBv0+Sk84CSQtGnyhwXq6q+TrhmWNiwR2CRu2wH5zjyiwNoFqMN7aIOFhE\n TbLpe2+2PVg3aJBtJzZ/mfkX6cAeWLSL08V8ZfG0EQIA/39Een2F9yZYlfiig+ZPmwhOz5+UHm0\n Z/KkOeK1zD3AE+u48GK8n1lXGq8h1UjpG8kkVWfQ9Glqmykvz3FzqR5N/vnxXg9KjLtniQtt7t8\n 5vPw/NBtFQQsKhacX5OTiLErAfRaGhwnP21u/9whv+PLxGsSiWyhkcY+Mnx2hYgs81SgiLIHjnN\n ZIrAT6PegVDC6KgUIoz3BDvBhkyzxA49R3ICh4uwF6T++hUHpLLUUUYAXQUgOdX4rgmNGH9+Eqf\n 3LdliJiv3cLZP1zywEAvHvxW+eOT0wfO3WNsICYdbAr/u5Iz/YW3pXI//5fL2ma32ewTd1Sui8k\n EgBhCTnNUFVcQDXVIOQ==",
        "X-Proofpoint-ORIG-GUID": "7FvTrm4NbLH8Lh1o67oJpfvFkvzVkHXE",
        "X-Authority-Analysis": "v=2.4 cv=Ipgutr/g c=1 sm=1 tr=0 ts=69e0d63c cx=c_pps\n a=mPf7EqFMSY9/WdsSgAYMbA==:117 a=5MtUiKxBt8oBE196zZFg1Q==:17\n a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22\n a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=mDV3o1hIAAAA:8\n a=EUspDBNiAAAA:8 a=KowNHAACC-JqpzDVimIA:9 a=dawVfQjAaf238kedN5IG:22",
        "X-Proofpoint-GUID": "7FvTrm4NbLH8Lh1o67oJpfvFkvzVkHXE",
        "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-16_03,2026-04-16_01,2025-10-01_01",
        "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n priorityscore=1501 bulkscore=0 clxscore=1015 impostorscore=0\n lowpriorityscore=0 adultscore=0 malwarescore=0 phishscore=0 spamscore=0\n suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc=\n route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604070000\n definitions=main-2604160119",
        "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": "From: Daniel Barboza <daniel.barboza@oss.qualcomm.com>\n\nCanonicalize right shift non-equality comparisons with constants by\nturn them into a comparison with a left shifted constant.  Assuming the\ngeneric format:\n\n(A >> CST1) CMP CST2\n\nFor CMP (<, >=) we'll compare A with CST2 left shifted by CST1:\n\n- (A >> CST1) < CST2  -> A < (CST2 << CST1)\n- (A >> CST1) >= CST2 -> A >= (CST2 << CST1)\n\nAnd for CMP (<=, >) we need to IOR the lower CST1 bits from the left\nshift:\n\n- (A >> CST1) <= CST2 -> A <= (CST2 << CST1) | mask\n- (A >> CST1) > CST2  -> A > (CST2 << CST1) | mask\n\nGiven that the right hand side changes involves just constants, in the\nend we'll replace a rshift + cmp with just a cmp.\n\nBootstrapped and regression tested in x86, aarch64 and RISC-V.\n\n\tPR tree-optimization/124808\n\ngcc/ChangeLog:\n\n\t* match.pd(`(A >> CST1) CMP CST2`): New pattern.\n\ngcc/testsuite/ChangeLog:\n\n\t* gcc.dg/tree-ssa/pr124808-2.c: New test.\n\t* gcc.dg/tree-ssa/pr124808.c: New test.\n---\n\nChanges from v2:\n- added \"#if GIMPLE\" and \"single_use\" conditions in the pattern\n- changed pr124808-2.c to scan 'forwprop1' dump instead of 'gimple'\n- reverted all changes made in sat-1.c\n- reverted all changes made in pr104479.c\n- v2 link: https://gcc.gnu.org/pipermail/gcc-patches/2026-April/713005.html\n\n gcc/match.pd                               | 58 ++++++++++++++++\n gcc/testsuite/gcc.dg/tree-ssa/pr124808-2.c | 44 ++++++++++++\n gcc/testsuite/gcc.dg/tree-ssa/pr124808.c   | 78 ++++++++++++++++++++++\n 3 files changed, 180 insertions(+)\n create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr124808-2.c\n create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr124808.c",
    "diff": "diff --git a/gcc/match.pd b/gcc/match.pd\nindex 7b652afb43d..8eece2223f9 100644\n--- a/gcc/match.pd\n+++ b/gcc/match.pd\n@@ -5367,6 +5367,64 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)\n       @0)))))\n #endif\n \n+#if GIMPLE\n+/* PR124808: (A >> CST1) CMP CST2 -> A CMP (CST2 << CST1)\n+   Canonicalize non-equality comparisons between a right\n+   shift and a constant, turning it into a comparison\n+   with a constant that is left shifted.  If we view A as:\n+\n+   A: \"|--- CST2 ----|--CST1--|\"\n+\n+   A >> CST1 will be equal to CST2 for all A values in the\n+   range CST2 << CST1 to (CST2 << CST1) | 1s_mask (CST1).\n+\n+   Therefore:\n+   - (A >> CST1) < CST2 -> A < (CST2 << CST1), A must\n+     be smaller than all values from the range;\n+   - (A >> CST1) <= CST2 -> A <= (CST2 << CST1) | mask,\n+     A must be smaller or equal than the range end;\n+   - (A >> CST1) > CST2 -> A > (CST2 << CST1) | mask,\n+     A must be greater than all values from the range;\n+   - (A >> CST1) >= CST2 -> A >= (CST2 << CST1), A must\n+     be greater or equal than the range start.\n+\n+   We're also using \"single_use\" and wrapping around \"if GIMPLE\"\n+   because (1) this class \"VA1 LSHIFT/RSHIFT VAL2 CMP VAL3\" of\n+   optimizations tend to match CTZ|CLZ builtin patterns and we\n+   don't want to trip on them and (2) we will get in the way of\n+   certain optimizations (see ARM's sat-1.c test) that are done\n+   using GENERIC due to how forwprop currently works.  */\n+(for cmp (le lt ge gt)\n+ (simplify\n+  (cmp (rshift@3 @0 INTEGER_CST@1) INTEGER_CST@2)\n+  (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))\n+       && single_use (@3)\n+       && tree_fits_uhwi_p (@1)\n+       && tree_to_uhwi (@1) < TYPE_PRECISION (TREE_TYPE (@0))\n+       && tree_int_cst_sgn (@2) >= 0\n+       /* If @2 is nonzero check if we'll overflow when doing\n+\t  @2 << @1 by doing a wi::lshift and checking if the\n+\t  result is zero (i.e. overflow).  */\n+       && (wi::to_wide (@2) == 0\n+\t   || !wi::eq_p (wi::lshift (wi::to_wide (@2), wi::to_wide (@1)),\n+\t\t\t wi::zero (TYPE_PRECISION (TREE_TYPE (@2))))))\n+\n+   /* No need to set the lower @1 bits of the resulting\n+      lshift for \"<\" and \">=\" comparisons.  */\n+   (if (cmp == LT_EXPR || cmp == GE_EXPR)\n+    (cmp @0 (lshift @2 @1))\n+\n+     /* For \"<=\" and \">\" set the lower @1 lshift bits.  */\n+     (with {\n+\ttree type2 = TREE_TYPE (@2);\n+\tunsigned prec = TYPE_PRECISION (type2);\n+\tunsigned mask_len = TREE_INT_CST_LOW (@1);\n+\twide_int cst1_mask = wi::mask (mask_len, false, prec);\n+      }\n+       (cmp @0 (bit_ior (lshift @2 @1)\n+\t\t\t{ wide_int_to_tree (type2, cst1_mask); })))))))\n+#endif\n+\n /* Rewrite an LROTATE_EXPR by a constant into an\n    RROTATE_EXPR by a new constant.  */\n (simplify\ndiff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr124808-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr124808-2.c\nnew file mode 100644\nindex 00000000000..bfab8109ce6\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr124808-2.c\n@@ -0,0 +1,44 @@\n+/* { dg-additional-options -O2 } */\n+/* { dg-additional-options -fdump-tree-forwprop1 } */\n+\n+long* SetupPrecalculatedData1 (long* a) {\n+  long b = 1;\n+  int i;\n+  for (i = 0; i < 64; i++) {\n+    if(i>>3 < 7)\n+      a[i] += (b<<(i+8));\n+  }\n+  return a;\n+}\n+\n+long* SetupPrecalculatedData2 (long* a) {\n+  long b = 1;\n+  int i;\n+  for (i = 0; i <= 64; i++) {\n+    if(i>>3 < 7)\n+      a[i] += (b<<(i+8));\n+  }\n+  return a;\n+}\n+\n+long* SetupPrecalculatedData3 (long* a) {\n+  long b = 1;\n+  int i;\n+  for (i = 0; i < 64; i++) {\n+    if(i>>3 > 7)\n+      a[i] += (b<<(i+8));\n+  }\n+  return a;\n+}\n+\n+long* SetupPrecalculatedData4 (long* a) {\n+  long b = 1;\n+  int i;\n+  for (i = 0; i < 64; i++) {\n+    if(i>>3 >= 7)\n+      a[i] += (b<<(i+8));\n+  }\n+  return a;\n+}\n+\n+/* { dg-final { scan-tree-dump-times \">> 3\" 0 forwprop1 } } */\ndiff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr124808.c b/gcc/testsuite/gcc.dg/tree-ssa/pr124808.c\nnew file mode 100644\nindex 00000000000..5f3c1f0a8c4\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr124808.c\n@@ -0,0 +1,78 @@\n+/* { dg-do run } */\n+/* { dg-options \"-O2\" } */\n+\n+void abort(void);\n+\n+/* Macro adapted from builtin-object-size-common.h  */\n+#define FAIL() \\\n+  do { \\\n+    __builtin_printf (\"Failure at line: %d\\n\", __LINE__);\t\\\n+    abort();\t\t\t\t\t\t\t\\\n+  } while (0)\n+\n+#define SHIFTVAL 3\n+#define CMPVAL 1\n+\n+long setValue1 (long in)\n+{\n+  if (in >> SHIFTVAL < CMPVAL)\n+    return in += SHIFTVAL;\n+  return -1;\n+}\n+\n+long setValue2 (long in)\n+{\n+  if (in >> SHIFTVAL <= CMPVAL)\n+    return in += SHIFTVAL;\n+  return -1;\n+}\n+\n+long setValue3 (long in)\n+{\n+  if (in >> SHIFTVAL > CMPVAL)\n+    return in += SHIFTVAL;\n+  return -1;\n+}\n+\n+long setValue4 (long in)\n+{\n+  if (in >> SHIFTVAL >= CMPVAL)\n+    return in += SHIFTVAL;\n+  return -1;\n+}\n+\n+int main (void) {\n+  /* setValue1: in << 3 < 1;  */\n+  if (setValue1 (7) != 10)\n+    FAIL ();\n+  if (setValue1 (8) != -1)\n+    FAIL ();\n+\n+  /* setValue2: in << 3 <= 1;  */\n+  if (setValue2 (7) != 10)\n+    FAIL ();\n+  if (setValue2 (8) != 11)\n+    FAIL ();\n+  if (setValue2 (15) != 18)\n+    FAIL ();\n+  if (setValue2 (16) != -1)\n+    FAIL ();\n+\n+  /* setValue3: in << 3 > 1;  */\n+  if (setValue3 (15) != -1)\n+    FAIL ();\n+  if (setValue3 (16) != 19)\n+    FAIL ();\n+\n+  /* setValue4: in << 3 >= 1;  */\n+  if (setValue4 (7) != -1)\n+    FAIL ();\n+  if (setValue4 (8) != 11)\n+    FAIL ();\n+  if (setValue4 (15) != 18)\n+    FAIL ();\n+  if (setValue4 (16) != 19)\n+    FAIL ();\n+\n+  return 0;\n+}\n",
    "prefixes": [
        "v3"
    ]
}