get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2223608,
    "url": "http://patchwork.ozlabs.org/api/1.1/patches/2223608/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260415175748.2714868-1-daniel.barboza@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": "<20260415175748.2714868-1-daniel.barboza@oss.qualcomm.com>",
    "date": "2026-04-15T17:57:48",
    "name": "[v2] match.pd: right shift compare canonicalization [PR124808]",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "343407ca6fbf966a825f72ee091c33833a649242",
    "submitter": {
        "id": 92288,
        "url": "http://patchwork.ozlabs.org/api/1.1/people/92288/?format=api",
        "name": "Daniel Henrique Barboza",
        "email": "daniel.barboza@oss.qualcomm.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260415175748.2714868-1-daniel.barboza@oss.qualcomm.com/mbox/",
    "series": [
        {
            "id": 500026,
            "url": "http://patchwork.ozlabs.org/api/1.1/series/500026/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500026",
            "date": "2026-04-15T17:57:48",
            "name": "[v2] match.pd: right shift compare canonicalization [PR124808]",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/500026/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2223608/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2223608/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=pass (2048-bit key;\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=DZ/oDDtC;\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=BJW5Ih/K;\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=DZ/oDDtC;\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=BJW5Ih/K",
            "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.168.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 4fwpm468Y2z1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 03:58:27 +1000 (AEST)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 9356F4BA2E32\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 17:58:25 +0000 (GMT)",
            "from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com\n [205.220.168.131])\n by sourceware.org (Postfix) with ESMTPS id 327E94BA2E06\n for <gcc-patches@gcc.gnu.org>; Wed, 15 Apr 2026 17:57:56 +0000 (GMT)",
            "from pps.filterd (m0279862.ppops.net [127.0.0.1])\n by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 63FELKH7764381\n for <gcc-patches@gcc.gnu.org>; Wed, 15 Apr 2026 17:57:54 GMT",
            "from mail-qv1-f71.google.com (mail-qv1-f71.google.com\n [209.85.219.71])\n by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dj6q7t776-1\n (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n for <gcc-patches@gcc.gnu.org>; Wed, 15 Apr 2026 17:57:54 +0000 (GMT)",
            "by mail-qv1-f71.google.com with SMTP id\n 6a1803df08f44-8a22dbeeb96so155319366d6.3\n for <gcc-patches@gcc.gnu.org>; Wed, 15 Apr 2026 10:57:54 -0700 (PDT)",
            "from QCOM-UWl2o8bcGT.qualcomm.com ([179.135.35.92])\n by smtp.gmail.com with ESMTPSA id\n 6a1803df08f44-8ae6c9394fdsm16830656d6.10.2026.04.15.10.57.50\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 15 Apr 2026 10:57:51 -0700 (PDT)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org 9356F4BA2E32",
            "OpenDKIM Filter v2.11.0 sourceware.org 327E94BA2E06"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 327E94BA2E06",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 327E94BA2E06",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776275876; cv=none;\n b=gI11ZNiuxo5g3fj16KMeHseBK+kOP1OqsaTm3DqADBrnDtYkgQVmlU+VBiZkNlCciUVeEfn+yxstXFTWpS5fLGKFp+q02jfNOjXM3MehJ34u/V4nRfXYmpe9uLreATrU2jEpsi/OAmN13DNmm9lGx3x7rrItYj/Gv+MHX3NPzG4=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776275876; c=relaxed/simple;\n bh=rKgSIlXSbgUEkSdAXAj9lbEyX1NZ0irLcmPx5dFrDZg=;\n h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID:\n MIME-Version;\n b=nXlqVkWRP8j2M2zwHaHDxxiDZswTGwUunewjKZup/eRAkrTk/vw9pcJOWkgTYxDKAwyK4ZRQ0xf/sETsu/F8B5Hbwqj/nvNo2Ev34eCDGAynPsnRtNnXl5JMZmVYesJAciRTQ5XZsXl9NcWpX4nHZ/4GCkjWtWpl0MdYMVIu3AM=",
        "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=gbwHAT7xd3AR6glrdrk54oeEJXbKByD1jjD\n BwhXIOas=; b=DZ/oDDtCKAFERHXqpLWEXIeotfblbes+cGTRc/cdQv1rQo9DPAj\n HxxBnYsGFF/SsaPbAkosQJm+GybmGu6Yr9iQUKeR8eELb+FuKa9nc5LaELrz3yTD\n pf97yib5osvepyGZguKgs0la8AY3LeE+fhOcZla0o+wjaeavUTno8PU+YV5BbtP1\n UBeX0iLL4eRrYQ8cZ65FgalEZoKm9LefSDnXuSK9+ccOYTpnzcdJSfG2D3V2pUfq\n zeQg6sVj+E/Uz/Pnod23sW+P5peaD9RLj7MR2GqAMRuZTQt0FMPiuF++rEWOS9X5\n wB5WbRuIW8KRSDSbRHK6KN4w17nqz05O8yA==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=oss.qualcomm.com; s=google; t=1776275873; x=1776880673; 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=gbwHAT7xd3AR6glrdrk54oeEJXbKByD1jjDBwhXIOas=;\n b=BJW5Ih/KtIA3X9DNZiiZmPjPeQdm8R8rQqHB6qRp3s+nAz80tWIiNd2qry3xkFfmwB\n RNPg1uUFw5lxgylL8sSwvYl4anCwh19vCDTWh6RNrKmAAmHwVb3jzUZ+aSM9sxd6PRSL\n tQ1iqF9j9oy5Cg3F93+XhtD+exSkDkVU2PB2IT6SCWVzV5R81FDoJ94bZ1XZl5OMaSRf\n ar3tS/zhN1zhBtHmZgIdBKdoXXHj9gn8xaSfK5nlVDJbA34Gibip4YCDf6i15/wGUR20\n nlh6ScGKe4EfTVOWQTR7Bs/k2E/79L954YZrVTyvcL2WNLbWkLKk3MKscYoaJgt5RV2C\n c7NQ=="
        ],
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776275873; x=1776880673;\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=gbwHAT7xd3AR6glrdrk54oeEJXbKByD1jjDBwhXIOas=;\n b=jpOGPSKgX76iCjQRCZuSMeB32ak6NqGdzvK2m7VpJ9CM6Ni+Jpv2csVCN91qa+bM0/\n tfkUNwo5oIuNjNCBYHDuXjRAIKcEha1/W83lHyKMF1t3Zwh9XAXnOXPrf7HQcurXbpa7\n QudNBvw+C4vxmsUopktNQHEbMjmLoM2b2jw1xr9F0gOfuj6fDmSzfAyze9tIvyaZlyk3\n NDAmFqtXhk3CUCBN9Ky+q0kX3zfZXpG4El5nH9GeBujSlul7FbBpj8f95MaCx6xyWCtk\n aZd9vMuKuIekH4xakF09NhkCfDw8xU4XiWFjEr01g8w2ufj1s/VzOgTVimHaAfYIoWIP\n 384w==",
        "X-Gm-Message-State": "AOJu0YzN+c9WT9P0ATTM2e5rp0Q+kMPu2bWZev+3Q69qyuLFZYzT3htF\n 2G4X54GsCJWtlpL7dqS3Rjw2BpsHVcVhEreHQtGFtiCFpRlXdZ7YKmZs8hiikTVicY+a2tlTlx/\n mQIbvZnIGljHW940/kMRw5lItPvzbFciDF57wPR3qJHHOWuVv16MhMYeHYfTuGyob3qcS",
        "X-Gm-Gg": "AeBDievy7rPwaJPVO2d0NOT4cPMraF9P993nIINMaimzO3VSM9l0x7+/En5/AFHUM79\n TPWtFY+WtkaPcVCVTNV+ZVI5eCKw8rx6I8Ae4svhondeDg2E290NxifGxEEXdVGOLjN3uWpZKwR\n Xk8ETUAWKGO9GxRpE+UYh+bvW/rocfnEqYIy8j7l5qUcxM7EpJVQuKYYvR25dDWgpQ7g6f35k/K\n hskAiXmtLL37vCP/F95G9Y72TSPwcn7qwxgzDTQIbO7BMGf3kee7b9hBRu50q5/wsMnsi46FQSy\n hEfPCnInBztzCvHUQs2nzvU+P5fBp3+PDrYTGU0PPbWPNrAtjmXZfTXhMiblWNX0iPaMGlSSr+C\n VlMGVcc1d2dmLyvUoeafIXk5HJUwrjINgOE6qsS6JliWk07Lt9eeWuLMQoKwJpAgF1AFN",
        "X-Received": [
            "by 2002:a05:6214:5244:b0:8a4:7977:e5fa with SMTP id\n 6a1803df08f44-8ac861a16e5mr362780906d6.25.1776275872893;\n Wed, 15 Apr 2026 10:57:52 -0700 (PDT)",
            "by 2002:a05:6214:5244:b0:8a4:7977:e5fa with SMTP id\n 6a1803df08f44-8ac861a16e5mr362780276d6.25.1776275872303;\n Wed, 15 Apr 2026 10:57:52 -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 v2] match.pd: right shift compare canonicalization [PR124808]",
        "Date": "Wed, 15 Apr 2026 14:57:48 -0300",
        "Message-ID": "<20260415175748.2714868-1-daniel.barboza@oss.qualcomm.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Authority-Analysis": "v=2.4 cv=AvHeGu9P c=1 sm=1 tr=0 ts=69dfd1a2 cx=c_pps\n a=UgVkIMxJMSkC9lv97toC5g==:117 a=KyJ3S0LjDRcVxFrLRjekIg==:17\n a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22\n a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=mDV3o1hIAAAA:8\n a=EUspDBNiAAAA:8 a=y5Ub4NFciHrjIelJiQkA:9 a=1HOtulTD9v-eNWfpl4qZ:22",
        "X-Proofpoint-GUID": "f8VHazMUU5nSgSp5DGFws10I2B_aYN3n",
        "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwNDE1MDE2NyBTYWx0ZWRfX4o8uDrO/l2a8\n l+Gz1+c3GRhm2bR+OJiLwWauilfWLBhPsWPYjtrpzQ8rGUzXRriqUnU5JBnTIUsmXBc859iQ8Sr\n pHeuwZKZn6ThCHtnTooPrA3/navH3CpY5cOkAdZk0uRVmfLgJT/aG/NngrUXARAvRhEC1NLxFzh\n +SGbclG/SPvbp7akVG/qY2CUMB54wLxNAi524T2ANemhmuSD65WcrBddTtJFN1VrzuZQjb/nfB3\n tdrjb5MW1AYKcVkfUT0Tz77gDq00UfMfFxBQd43FeLjH31eT3mXgwjSY0iOgMmyq04MMIhyFVGc\n SgaTzSEZixEK3pfw83UEmvDVtMnJtcl3zYrJruojPhndnPUpiYQQBGyQZ4ziVjmoCCLZ167vkLH\n zea9SXzlw9QyJoa1Hv1HDIojWwiKM76vlZbJDx1ovaKytHfQI57AuuypUDJhz1NQpyuUYkiW4qs\n la8cKSvLr8d5aEwNTZQ==",
        "X-Proofpoint-ORIG-GUID": "f8VHazMUU5nSgSp5DGFws10I2B_aYN3n",
        "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-15_01,2026-04-13_04,2025-10-01_01",
        "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n malwarescore=0 spamscore=0 clxscore=1015 adultscore=0 phishscore=0\n bulkscore=0 suspectscore=0 priorityscore=1501 impostorscore=0\n lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc=\n route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604070000\n definitions=main-2604150167",
        "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.target/arm/sat-1.c: Changed rshift GE/LE patterns to use\n\ta bit_xor instead, avoiding the transformation to be applied and\n\tpreserving the test behavior.\n\t* gcc.target/i386/pr104479.c: Change 'cond_shr' to use a NE\n\tcompare instead of a GE compare, making the test behave as\n\texpected without this transformation.\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 v1:\n- changed shift amount check to use free_fits_uhwi_p\n- use tree_int_cst_sgn() to check for positive CST2\n- use wi:to_wide() == 0 to check for @2 == 0\n- fixed regression on sat-1.c\n- fixed typo in match.pd comment\n- v1 link: https://gcc.gnu.org/pipermail/gcc-patches/2026-April/712779.html\n\n gcc/match.pd                               | 52 +++++++++++++++\n gcc/testsuite/gcc.dg/tree-ssa/pr124808-2.c | 44 ++++++++++++\n gcc/testsuite/gcc.dg/tree-ssa/pr124808.c   | 78 ++++++++++++++++++++++\n gcc/testsuite/gcc.target/arm/sat-1.c       |  8 +--\n gcc/testsuite/gcc.target/i386/pr104479.c   |  2 +-\n 5 files changed, 179 insertions(+), 5 deletions(-)\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 7f16fd4e081..5c9172d89e6 100644\n--- a/gcc/match.pd\n+++ b/gcc/match.pd\n@@ -5367,6 +5367,58 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)\n       @0)))))\n #endif\n \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 \":s\" given that this class of optimizations\n+   \"VA1 LSHIFT/RSHIFT VAL2 CMP VAL3\" tend to match CTZ|CLZ\n+   builtin patterns.  */\n+(for cmp (le lt ge gt)\n+ (simplify\n+  (cmp (rshift:s @0 INTEGER_CST@1) INTEGER_CST@2)\n+  (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))\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+\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..c6a20467645\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-gimple } */\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 gimple } } */\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+}\ndiff --git a/gcc/testsuite/gcc.target/arm/sat-1.c b/gcc/testsuite/gcc.target/arm/sat-1.c\nindex ebde56a4554..b2a95924da3 100644\n--- a/gcc/testsuite/gcc.target/arm/sat-1.c\n+++ b/gcc/testsuite/gcc.target/arm/sat-1.c\n@@ -26,7 +26,7 @@ int u1 (int x)\n \n int us1 (int x)\n {\n-  return sat1 (x >> 5, 0, 63);\n+  return sat1 (x ^ 0xFF, 0, 63);\n }\n \n int s1 (int x)\n@@ -36,7 +36,7 @@ int s1 (int x)\n \n int ss1 (int x)\n {\n-  return sat1 (x >> 5, -64, 63);\n+  return sat1 (x ^ 0xFF, -64, 63);\n }\n \n int u2 (int x)\n@@ -46,7 +46,7 @@ int u2 (int x)\n \n int us2 (int x)\n {\n-  return sat2 (x >> 5, 0, 63);\n+  return sat2 (x ^ 0xFF, 0, 63);\n }\n \n int s2 (int x)\n@@ -56,7 +56,7 @@ int s2 (int x)\n \n int ss2 (int x)\n {\n-  return sat2 (x >> 5, -64, 63);\n+  return sat2 (x ^ 0xFF, -64, 63);\n }\n \n /* { dg-final { scan-assembler-times \"usat\" 4 } } */\ndiff --git a/gcc/testsuite/gcc.target/i386/pr104479.c b/gcc/testsuite/gcc.target/i386/pr104479.c\nindex 4ca4c482542..ff5603aae7b 100644\n--- a/gcc/testsuite/gcc.target/i386/pr104479.c\n+++ b/gcc/testsuite/gcc.target/i386/pr104479.c\n@@ -12,7 +12,7 @@ cond_shr (unsigned int* __restrict dst,\n   for(int x = 0; x < i_width; x++)\n     {\n       unsigned int temp = src[x] >> 3;\n-      dst[x] =  temp > 255 ? temp : y[x];\n+      dst[x] =  temp != 255 ? temp : y[x];\n     }\n }\n \n",
    "prefixes": [
        "v2"
    ]
}