get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2232259,
    "url": "http://patchwork.ozlabs.org/api/patches/2232259/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260504060347.134425-1-Reshma.Roy@amd.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": "<20260504060347.134425-1-Reshma.Roy@amd.com>",
    "list_archive_url": null,
    "date": "2026-05-04T06:03:47",
    "name": "[v2] Enabling POPCNT generation for 32-bit patterns.",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "e7c64cf859b202b165e7ace42e3e49c8cce6cf98",
    "submitter": {
        "id": 92489,
        "url": "http://patchwork.ozlabs.org/api/people/92489/?format=api",
        "name": "Reshma Roy",
        "email": "Reshma.Roy@amd.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260504060347.134425-1-Reshma.Roy@amd.com/mbox/",
    "series": [
        {
            "id": 502613,
            "url": "http://patchwork.ozlabs.org/api/series/502613/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=502613",
            "date": "2026-05-04T06:03:47",
            "name": "[v2] Enabling POPCNT generation for 32-bit patterns.",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/502613/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2232259/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2232259/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=amd.com header.i=@amd.com header.a=rsa-sha256\n header.s=selector1 header.b=LAAvbAXT;\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=amd.com header.i=@amd.com header.a=rsa-sha256\n header.s=selector1 header.b=LAAvbAXT",
            "sourceware.org;\n dmarc=pass (p=quarantine dis=none) header.from=amd.com",
            "sourceware.org; spf=fail smtp.mailfrom=amd.com",
            "server2.sourceware.org;\n arc=pass smtp.remote-ip=2a01:111:f403:c10d::1"
        ],
        "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 4g8B1q0s4cz1yJ9\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 04 May 2026 16:04:45 +1000 (AEST)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id DF17A4BABF28\n\tfor <incoming@patchwork.ozlabs.org>; Mon,  4 May 2026 06:04:43 +0000 (GMT)",
            "from SN4PR2101CU001.outbound.protection.outlook.com\n (mail-southcentralusazlp170120001.outbound.protection.outlook.com\n [IPv6:2a01:111:f403:c10d::1])\n by sourceware.org (Postfix) with ESMTPS id C4E944B9DB6E\n for <gcc-patches@gcc.gnu.org>; Mon,  4 May 2026 06:04:11 +0000 (GMT)",
            "from MN2PR19CA0062.namprd19.prod.outlook.com (2603:10b6:208:19b::39)\n by PH7PR12MB6858.namprd12.prod.outlook.com (2603:10b6:510:1b4::20)\n with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9870.25; Mon, 4 May\n 2026 06:04:04 +0000",
            "from MN1PEPF0000ECD5.namprd02.prod.outlook.com\n (2603:10b6:208:19b:cafe::d7) by MN2PR19CA0062.outlook.office365.com\n (2603:10b6:208:19b::39) with Microsoft SMTP Server (version=TLS1_3,\n cipher=TLS_AES_256_GCM_SHA384) id 15.20.9870.25 via Frontend Transport; Mon,\n 4 May 2026 06:04:04 +0000",
            "from satlexmb07.amd.com (165.204.84.17) by\n MN1PEPF0000ECD5.mail.protection.outlook.com (10.167.242.133) with Microsoft\n SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.20.9891.9 via Frontend Transport; Mon, 4 May 2026 06:04:03 +0000",
            "from amd-MS-7D67.amd.com (10.180.168.240) by satlexmb07.amd.com\n (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Mon, 4 May\n 2026 01:04:01 -0500"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org DF17A4BABF28",
            "OpenDKIM Filter v2.11.0 sourceware.org C4E944B9DB6E"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org C4E944B9DB6E",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org C4E944B9DB6E",
        "ARC-Seal": [
            "i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1777874652; cv=pass;\n b=J0wkKO13CM6ox553f2OCBmjuFiEPFuZVMY5csgz0o7Gk0Xv5vKZU2Jr4fu2Rpr6AzMi25PjzoWBWwUIHW2CmBE9CPnn/4C9QLfFVawHB6oM24ichqyx3rdH6EB8GiaBzkUawG1vHcKwh/l2avLYj1X9OmYl2LTdiOMFgSYhAQR8=",
            "i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n b=zQC0jTRf3iH8hrjiaY5Kj0m2xRo6Odi48YHdN3rPMlqW76QQsF6Ew8+jJQ01EOKiQMp7pedOaJykFs4F6SXSxKeAumgkZX2y2XZZdrNmb4+YreOEFz7oMez/HGkUsole6t3hoNC9jP4omWRxnVoLbRPnnaui0LwI1AqfeuBALTZhrCCK2fLpvDjdVDZJTIMKs8MMOmY0gp0JI6K2f+QiV9GdMIvsFf3Cw4b6uYsQXg14yxUKFDVyZCFZvygHzgOraL8uLeETkkZ3xY4CdBo0qFKKVxGtrVpNLZgQtX41V3qMkFmdcIR3N285zbbAY+QxuIKnT6gTAfEUH94rS4uV2g=="
        ],
        "ARC-Message-Signature": [
            "i=2; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777874652; c=relaxed/simple;\n bh=9/OFtH2NN8/8fOZhVd2goiFf5Gdcb1KjC529xVSrbJs=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=Xk3hVazyHyKV2TAZozOTWhZx7s37Kkj3R0mbSa5zuVrPlzcZWlghsR9mkwmMg2MTGyNEo0Hd7ahMh/OL3a6PN2/F+jSOGZEV9WnqP0yMvFfKPqY9e9wyWdUxS4OwrA+tyJO9dQlzOxuzphHI5AkVNXTMNEsjiWBlkZGwFNXTGsY=",
            "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector10001;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n bh=ctrEmWFhx3REk56JcB1+ScpVFgYG9d5sQ6Ug5/f/OuU=;\n b=GpAWmBOJBWY18wESznCUAOpzGZTyMlWOlJzA8jgZ0IGzgMHw6BTwWdiaqa7/PR1Jur2J9kfvtYbG5Bu5ARnOcNYurLTuKvUJVlrX3QVQLaya8EjtewECHgWlh7WFgeyG1xWkb4E0E37wnwVfIKO+O/BG5YlBIsv+U/fNSNPeKqgcRz6aAHbkqh1l7h2UVB41JcdTYpim2+6V8cpKOA+RwlogF8DxWRYprV73ebwXTDxqhS4INNjWODB733Ssp5wh45lwEER7922sV0jHxiFo9FociV75GG7eVfyaGVEH0ARX7e3guWBpOErn5ttBi+pK+se0GiYI7FIlVlPsiOmQzQ=="
        ],
        "ARC-Authentication-Results": [
            "i=2; server2.sourceware.org",
            "i=1; mx.microsoft.com 1; spf=pass (sender ip is\n 165.204.84.17) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=amd.com;\n dmarc=pass (p=quarantine sp=quarantine pct=100) action=none\n header.from=amd.com; dkim=none (message not signed); arc=none (0)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=ctrEmWFhx3REk56JcB1+ScpVFgYG9d5sQ6Ug5/f/OuU=;\n b=LAAvbAXT90TNEz9vhGBwS0eC7cyX+hDu0WGPyLVYh5ce3Jmce4n3DVWv9ffpQdPYMbyGXdKIqOeiLEMgc3blIqr2lgW1W/RsdU+OyT1xEwU9xp97v1YA4jSkTDvlhlSWU5rnkrFEAgpX6UAgzwUJai+ToWztF9H2Cc+4vxN+VTM=",
        "X-MS-Exchange-Authentication-Results": "spf=pass (sender IP is 165.204.84.17)\n smtp.mailfrom=amd.com; dkim=none (message not signed)\n header.d=none;dmarc=pass action=none header.from=amd.com;",
        "Received-SPF": "Pass (protection.outlook.com: domain of amd.com designates\n 165.204.84.17 as permitted sender) receiver=protection.outlook.com;\n client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C",
        "From": "Reshma Roy <Reshma.Roy@amd.com>",
        "To": "<gcc-patches@gcc.gnu.org>",
        "CC": "<rguenther@suse.de>, <venkataramanan.kumar@amd.com>, Reshma Roy\n <Reshma.Roy@amd.com>",
        "Subject": "[PATCH v2] Enabling POPCNT generation for 32-bit patterns.",
        "Date": "Mon, 4 May 2026 11:33:47 +0530",
        "Message-ID": "<20260504060347.134425-1-Reshma.Roy@amd.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<47590p5q-07n2-p9n8-sq12-n810ro496387@fhfr.qr>",
        "References": "<47590p5q-07n2-p9n8-sq12-n810ro496387@fhfr.qr>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.180.168.240]",
        "X-ClientProxiedBy": "satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com\n (10.181.42.216)",
        "X-EOPAttributedMessage": "0",
        "X-MS-PublicTrafficType": "Email",
        "X-MS-TrafficTypeDiagnostic": "MN1PEPF0000ECD5:EE_|PH7PR12MB6858:EE_",
        "X-MS-Office365-Filtering-Correlation-Id": "01161c03-0132-4211-3d03-08dea9a2f1c0",
        "X-MS-Exchange-SenderADCheck": "1",
        "X-MS-Exchange-AntiSpam-Relay": "0",
        "X-Microsoft-Antispam": "BCL:0;\n ARA:13230040|36860700016|82310400026|376014|1800799024|13003099007|18002099003|22082099003|56012099003;",
        "X-Microsoft-Antispam-Message-Info": "\n p8wyHjy/an4GNvFhrOXtzzcSJq2jEl7H+uzb494+VHVk9KGS8ZSO/HbutPQon6xZxPHwJGKlbuMmW6Q7qB8jwnyRVIkx2e/a8cqiBFhlq4aUHhBlz+bAMucIvzZXVh/EXU3QusYX+y5TzPTbJ1qlsNtJn6BUWwz15Ywt6zKPHhTxFG6aQuqsza0cPzRXbO8b1+1eVfFdCGkZJM+LShxISgT2EdqCKxh5HNc/E/uyCQd+dB4x0YGww9uYvtbMyL5QI0HWMFrY5pUNR4Ij2teI0rxah7vJyoqp/jJ3QyomMAfwJBKh62Oizmdr2GV9P0ehtImnjHEnYqnabqRJvnJ3VbEr0AlWYGq4fUQeJriKd2M7aXnlThtYD/RvKsCL8rdL2tGHtEs0W3rC1vOAlDAgDlv5My+QFQtqJWRjJOR6MYFCFoQORoqJbCSVag1M2Q3z51coE/b5XWF5XB0ZPsKGj+u7xx7K/KBwwzgqiToskjw4kiXG+UC7ORZp/klp/rCq8cFWrWG/rYEejHIxgAfXrdf79rXs1H3lYCTl9/dh+CY3KVz6kGbunjYnDZj05nTBAh09vnQUJMqda+t270prMiXPbkjJr/hbgOjLO6lHLHGonGmnRIpkunyCvho3Pmh3nn9oIgTjdGacl5y7m4UWw1rc3HjR7k3qnA/eVOHFRxlTIe7BkaO+lyKJZmkStkTD",
        "X-Forefront-Antispam-Report": "CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:;\n IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE;\n SFS:(13230040)(36860700016)(82310400026)(376014)(1800799024)(13003099007)(18002099003)(22082099003)(56012099003);\n DIR:OUT; SFP:1101;",
        "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1",
        "X-MS-Exchange-AntiSpam-MessageData-0": "\n kXrU8dj3WQlP2OrtqCn8hVxwwTyRrbGl2957zkPQbjNeEpec0+liL1f7BbRTbWKQmoOWoyvjA532xzBxeBfded3+88pwbnGdV/H0PLraGqo+rc4FQFWbpN9UdHoC7wy2Mq9g7grkbcXbv/wNd/n+HLszdIq0FFwFAHHnbB/0lX/KRsCq87ydn2qd/MMI3LsQmSSzaho17aM9zdEx3eZhX6X1FJnNm1xpkpZm5wmyISmJz5eHyQioQw8JCfEhQRssIgccLJR11OCJqjCZZrj3Nydy6KdOorKJqgrAX5NFC+qN2uYcWbzFS5ID9QV4SG42Cxtl9MTvUnper7MypFDivKgOLKU10x1/8Fai9Y0s2ws+aIUg9sZFVf/WOfKl8zoPOpCkBUint+WfkBXu0NwL2V7RLBfysAxP+lx6uTySSc4WUoMVs40qmeIfTRFGJX8R",
        "X-OriginatorOrg": "amd.com",
        "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "04 May 2026 06:04:03.8456 (UTC)",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n 01161c03-0132-4211-3d03-08dea9a2f1c0",
        "X-MS-Exchange-CrossTenant-Id": "3dd8961f-e488-4e60-8e11-a82d994e183d",
        "X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp": "\n TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17];\n Helo=[satlexmb07.amd.com]",
        "X-MS-Exchange-CrossTenant-AuthSource": "\n MN1PEPF0000ECD5.namprd02.prod.outlook.com",
        "X-MS-Exchange-CrossTenant-AuthAs": "Anonymous",
        "X-MS-Exchange-CrossTenant-FromEntityHeader": "HybridOnPrem",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "PH7PR12MB6858",
        "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": "Enabling POPCNT generation for 32-bit pattern from Hacker's Delight\n\nPattern 1:\nint Gia_WordCountOnes32c( uint32_t uword )\n{\n  uword = (uword & 0x55555555) + ((uword>>1) & 0x55555555);\n  uword = (uword & 0x33333333) + ((uword>>2) & 0x33333333);\n  uword = (uword & 0x0f0f0f0f) + ((uword>>4) & 0x0f0f0f0f);\n  uword = (uword & 0x00ff00ff) + ((uword>>8) & 0x00ff00ff);\n  return  (uword & 0x0000ffff) + (uword>>16);\n  or\n  return (uword & 0x0000FFFF) + ((uword >> 16) & 0x0000FFFF);\n}\n\nPattern 2:\nint pop(unsigned x) {\n  x = x - ((x >> 1) & 0x55555555);\n  x = (x & 0x33333333) + ((x >> 2) & 0x33333333);\n  x = (x + (x >> 4)) & 0x0F0F0F0F;\n  x = x + (x >> 8);\n  x = x + (x >> 16);\n  return x & 0x0000003F;\n}\n\nPattern 3:\nint pop(unsigned x) {\n  x = x - ((x >> 1) & 0x55555555);\n  x = x - 3*((x >> 2) & 0x33333333)\n    x = (x + (x >> 4)) & 0x0F0F0F0F;\n  x = x + (x >> 8);\n  x = x + (x >> 16);\n  return x & 0x0000003F;\n}\n\ngcc/ChangeLog:\n\n* match.pd: Add new popcount pattern variants from Hacker's Delight.\n\ngcc/testsuite/ChangeLog:\n\n* gcc.dg/tree-ssa/popcount7.c: New test.\n* gcc.dg/tree-ssa/popcount7_2.c: New test.\n* gcc.dg/tree-ssa/popcount8.c: New test.\n* gcc.dg/tree-ssa/popcount9.c: New test.\n\n---\n\n[Public] \n\nHi Richard,\n\n   I have rebased this patch and am reposting it now after the release. Please let me know if you have any further feedback.\n\n   Bootstrapped and tested on x86.\n\nThank You,\nReshma Roy\n\n\n gcc/match.pd                                | 187 ++++++++++++++++++++\n gcc/testsuite/gcc.dg/tree-ssa/popcount7.c   |  23 +++\n gcc/testsuite/gcc.dg/tree-ssa/popcount7_2.c |  23 +++\n gcc/testsuite/gcc.dg/tree-ssa/popcount8.c   |  22 +++\n gcc/testsuite/gcc.dg/tree-ssa/popcount9.c   |  22 +++\n 5 files changed, 277 insertions(+)\n create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/popcount7.c\n create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/popcount7_2.c\n create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/popcount8.c\n create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/popcount9.c",
    "diff": "diff --git a/gcc/match.pd b/gcc/match.pd\nindex 7db8ce7580f..d36dfefcd07 100644\n--- a/gcc/match.pd\n+++ b/gcc/match.pd\n@@ -11167,6 +11167,193 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)\n    (plus (CTZ:type (convert:utype @0)) { build_one_cst (type); }))))\n #endif\n \n+#if GIMPLE\n+/* To recognize the popcnt pattern for 32-bit from Hacker's Delight\n+   int Gia_WordCountOnes32c ( uint32_t uword)\n+   {\n+   uword = (uword & 0x55555555) + ((uword>>1) & 0x55555555);\n+   uword = (uword & 0x33333333) + ((uword>>2) & 0x33333333);\n+   uword = (uword & 0x0f0f0f0f) + ((uword>>4) & 0x0f0f0f0f);\n+   uword = (uword & 0x00ff00ff) + ((uword>>8) & 0x00ff00ff);\n+   return (uword & 0x0000ffff) + (uword>>16);\n+   or\n+   return (uword & 0x0000ffff) + ((uword>>16) & 0x0000ffff);\n+   }\n+*/\n+\n+  (simplify\n+     (plus:c\n+       (bit_and @step_4 INTEGER_CST@9)\n+       (rshift\n+\t (plus:c@step4\n+\t   (bit_and @step3 INTEGER_CST@7)\n+\t(bit_and\n+\t   (rshift\n+\t      (plus:c@step3\n+\t\t  (bit_and @step2 INTEGER_CST@5)\n+\t\t  (bit_and\n+\t\t     (rshift\n+\t\t\t(plus:c@step2\n+\t\t\t   (bit_and @step1 INTEGER_CST@3)\n+\t\t\t   (bit_and\n+\t\t\t      (rshift\n+\t\t\t\t  (plus:c@step1\n+\t\t\t\t      (bit_and @0 INTEGER_CST@1)\n+\t\t\t\t      (bit_and (rshift @0 INTEGER_CST@2) @1))\n+\t\t\t\t  INTEGER_CST@4)\n+\t\t\t      INTEGER_CST@3))\n+\t\t\tINTEGER_CST@6)\n+\t\t     INTEGER_CST@5))\n+\t      INTEGER_CST@8)\n+\t   INTEGER_CST@7))\n+\t INTEGER_CST@10))\n+   (with {\n+    unsigned prec = TYPE_PRECISION (type);\n+    int shift = prec & 31 ;\n+    unsigned HOST_WIDE_INT c1 = HOST_WIDE_INT_UC (0x55555555) >> shift;\n+    unsigned HOST_WIDE_INT c2 = HOST_WIDE_INT_UC (0x33333333) >> shift;\n+    unsigned HOST_WIDE_INT c3 = HOST_WIDE_INT_UC (0x0F0F0F0F) >> shift;\n+    unsigned HOST_WIDE_INT c4 = HOST_WIDE_INT_UC (0x00FF00FF) >> shift;\n+    unsigned HOST_WIDE_INT c5 = HOST_WIDE_INT_UC (0x0000FFFF) >> shift;\n+    }\n+    (if (prec >= 16\n+\t && prec <= 32\n+\t && pow2p_hwi (prec)\n+\t && TYPE_UNSIGNED (type)\n+\t && integer_onep (@2)\n+\t && wi::to_widest (@4) == 2\n+\t && wi::to_widest (@6) == 4\n+\t && wi::to_widest (@8) == 8\n+\t && wi::to_widest (@10) == 16\n+\t && tree_to_uhwi (@1) == c1\n+\t && tree_to_uhwi (@3) == c2\n+\t && tree_to_uhwi (@5) == c3\n+\t && tree_to_uhwi (@7) == c4\n+\t && tree_to_uhwi (@9) == c5)\n+       (if (direct_internal_fn_supported_p (IFN_POPCOUNT, type,\n+\t\t\t\t\t    OPTIMIZE_FOR_BOTH))\n+\t(convert (IFN_POPCOUNT:type @0))))))\n+#endif\n+#if GIMPLE\n+/*To recognize the popcnt pattern for 32-bit from Hacker's Delight\n+int pop (unsigned x)\n+{\n+x = x - ((x >> 1) & 0x55555555);\n+x = (x & 0x33333333) + ((x >> 2) & 0x33333333);\n+x = x - 3*((x >> 2) & 0x33333333);\n+x = (x + (x >> 4)) & 0x0F0F0F0F;\n+x = x + (x >> 8);\n+x = x + (x >> 16);\n+return x & 0x0000003F\n+}\n+*/\n+(simplify\n+ (bit_and\n+   (plus\n+    (rshift @step4 INTEGER_CST@10)\n+     (plus:c@step4\n+\t(rshift @step3 INTEGER_CST@8)\n+\t   (bit_and@step3\n+\t     (plus\n+\t\t(rshift @step2 INTEGER_CST@6)\n+\t\t   (plus:c@step2\n+\t\t      (bit_and @step1 INTEGER_CST@3)\n+\t\t      (bit_and\n+\t\t\t  (rshift\n+\t\t\t    (minus@step1\n+\t\t\t     @0\n+\t\t\t     (bit_and (rshift @0 INTEGER_CST@2) INTEGER_CST@1))\n+\t\t\t    INTEGER_CST@4)\n+\t\t\t INTEGER_CST@3)))\n+\t     INTEGER_CST@5)))\n+   INTEGER_CST@7)\n+ (with {\n+   unsigned prec = TYPE_PRECISION (type);\n+   int shift = prec & 31 ;\n+   unsigned HOST_WIDE_INT c1 = HOST_WIDE_INT_UC (0x55555555) >> shift;\n+   unsigned HOST_WIDE_INT c2 = HOST_WIDE_INT_UC (0x33333333) >> shift;\n+   unsigned HOST_WIDE_INT c3 = HOST_WIDE_INT_UC (0x0F0F0F0F) >> shift;\n+   unsigned HOST_WIDE_INT c4 = HOST_WIDE_INT_UC (0x0000003F) >> shift;\n+   }\n+   (if (prec >= 16\n+\t&& prec <= 32\n+\t&& pow2p_hwi (prec)\n+\t&& TYPE_UNSIGNED (type)\n+\t&& integer_onep (@2)\n+\t&& wi::to_widest (@4) == 2\n+\t&& wi::to_widest (@6) == 4\n+\t&& wi::to_widest (@8) == 8\n+\t&& wi::to_widest (@10) == 16\n+\t&& tree_to_uhwi (@1) == c1\n+\t&& tree_to_uhwi (@3) == c2\n+\t&& tree_to_uhwi (@5) == c3\n+\t&& tree_to_uhwi (@7) == c4)\n+     (if (direct_internal_fn_supported_p (IFN_POPCOUNT, type,\n+\t\t\t\t\t  OPTIMIZE_FOR_BOTH))\n+\t(convert (IFN_POPCOUNT:type @0))))))\n+#endif\n+#if GIMPLE\n+\n+/*To recognize the popcnt pattern for 32-bit from Hacker's Delight\n+/*int pop (unsigned x)\n+{\n+  x = x - ((x >> 1) & 0x55555555);\n+  x = x - 3*((x >> 2) & 0x33333333)\n+  x = (x + (x >> 4)) & 0x0F0F0F0F;\n+  x = x + (x >> 8);\n+  x = x + (x >> 16);\n+  return x & 0x0000003F;\n+}\n+*/\n+(simplify\n+ (bit_and\n+   (plus\n+    (rshift @step4 INTEGER_CST@10)\n+     (plus:c@step4\n+\t(rshift @step3 INTEGER_CST@8)\n+\t   (bit_and@step3\n+\t      (plus\n+\t\t(rshift @step2 INTEGER_CST@6)\n+\t\t(minus@step2\n+\t\t   @step1\n+\t\t   (mult:c\n+\t\t      (bit_and\n+\t\t\t(rshift\n+\t\t\t  (minus@step1\n+\t\t\t     @0\n+\t\t\t     (bit_and (rshift @0 INTEGER_CST@2) INTEGER_CST@1))\n+\t\t\t  INTEGER_CST@4)\n+\t\t\tINTEGER_CST@3)\n+\t\t      INTEGER_CST@11)))\n+\t      INTEGER_CST@5)))\n+   INTEGER_CST@7)\n+ (with {\n+   unsigned prec = TYPE_PRECISION (type);\n+   int shift = prec & 31 ;\n+   unsigned HOST_WIDE_INT c1 = HOST_WIDE_INT_UC (0x55555555) >> shift;\n+   unsigned HOST_WIDE_INT c2 = HOST_WIDE_INT_UC (0x33333333) >> shift;\n+   unsigned HOST_WIDE_INT c3 = HOST_WIDE_INT_UC (0x0F0F0F0F) >> shift;\n+   unsigned HOST_WIDE_INT c4 = HOST_WIDE_INT_UC (0x0000003F) >> shift;\n+   }\n+   (if (prec >= 16\n+\t&& prec <= 32\n+\t&& pow2p_hwi (prec)\n+\t&& TYPE_UNSIGNED (type)\n+\t&& integer_onep (@2)\n+\t&& wi::to_widest (@4) == 2\n+\t&& wi::to_widest (@6) == 4\n+\t&& wi::to_widest (@8) == 8\n+\t&& wi::to_widest (@10) == 16\n+\t&& wi::to_widest (@11) == 3\n+\t&& tree_to_uhwi (@1) == c1\n+\t&& tree_to_uhwi (@3) == c2\n+\t&& tree_to_uhwi (@5) == c3\n+\t&& tree_to_uhwi (@7) == c4)\n+     (if (direct_internal_fn_supported_p (IFN_POPCOUNT, type,\n+\t\t\t\t\t  OPTIMIZE_FOR_BOTH))\n+\t(convert (IFN_POPCOUNT:type @0))))))\n+#endif\n+\n (for ffs (FFS)\n  /* __builtin_ffs (X) == 0 -> X == 0.\n     __builtin_ffs (X) == 6 -> (X & 63) == 32.  */\ndiff --git a/gcc/testsuite/gcc.dg/tree-ssa/popcount7.c b/gcc/testsuite/gcc.dg/tree-ssa/popcount7.c\nnew file mode 100644\nindex 00000000000..c70837fc53b\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/tree-ssa/popcount7.c\n@@ -0,0 +1,23 @@\n+/* { dg-do compile } */\n+/* { dg-require-effective-target popcount } */\n+/* { dg-require-effective-target int32plus } */\n+/* { dg-options \"-O2 -fdump-tree-optimized\" } */\n+\n+const unsigned m1  = 0x55555555UL;\n+const unsigned m2  = 0x33333333UL;\n+const unsigned m3  = 0x0F0F0F0FUL;\n+const unsigned m4  = 0x00FF00FFUL;\n+const unsigned m5  = 0x0000FFFFUL;\n+\n+int Gia_WordCountOnes32c( unsigned uword )\n+{\n+  uword = (uword & m1) + ((uword>>1) & m1);\n+  uword = (uword & m2) + ((uword>>2) & m2);\n+  uword = (uword & m3) + ((uword>>4) & m3);\n+  uword = (uword & m4) + ((uword>>8) & m4);\n+  return  (uword & m5) + (uword>>16);\n+}\n+\n+/* { dg-final { scan-tree-dump-times \"\\.POPCOUNT\" 1 \"optimized\" } } */\n+\n+\ndiff --git a/gcc/testsuite/gcc.dg/tree-ssa/popcount7_2.c b/gcc/testsuite/gcc.dg/tree-ssa/popcount7_2.c\nnew file mode 100644\nindex 00000000000..fc6c23b411b\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/tree-ssa/popcount7_2.c\n@@ -0,0 +1,23 @@\n+/* { dg-do compile } */\n+/* { dg-require-effective-target popcount } */\n+/* { dg-require-effective-target int32plus } */\n+/* { dg-options \"-O2 -fdump-tree-optimized\" } */\n+\n+const unsigned m1  = 0x55555555UL;\n+const unsigned m2  = 0x33333333UL;\n+const unsigned m3  = 0x0F0F0F0FUL;\n+const unsigned m4  = 0x00FF00FFUL;\n+const unsigned m5  = 0x0000FFFFUL;\n+\n+int Gia_WordCountOnes32c( unsigned uword )\n+{\n+  uword = (uword & m1) + ((uword>>1) & m1);\n+  uword = (uword & m2) + ((uword>>2) & m2);\n+  uword = (uword & m3) + ((uword>>4) & m3);\n+  uword = (uword & m4) + ((uword>>8) & m4);\n+  return  (uword & m5) + ((uword>>16) & m5);\n+}\n+\n+/* { dg-final { scan-tree-dump-times \"\\.POPCOUNT\" 1 \"optimized\" } } */\n+\n+\ndiff --git a/gcc/testsuite/gcc.dg/tree-ssa/popcount8.c b/gcc/testsuite/gcc.dg/tree-ssa/popcount8.c\nnew file mode 100644\nindex 00000000000..5a12e6892aa\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/tree-ssa/popcount8.c\n@@ -0,0 +1,22 @@\n+/* { dg-do compile } */\n+/* { dg-require-effective-target popcount } */\n+/* { dg-require-effective-target int32plus } */\n+/* { dg-options \"-O2 -fdump-tree-optimized\" } */\n+\n+const unsigned m1  = 0x55555555UL;\n+const unsigned m2  = 0x33333333UL;\n+const unsigned m3  = 0x0F0F0F0FUL;\n+const unsigned m4  = 0x0000003F;\n+\n+int pop32c(unsigned x) {\n+  x = x - ((x >> 1) & m1);\n+  x = (x & m2) + ((x >> 2) & m2);\n+  x = (x + (x >> 4)) & m3;\n+  x = x + (x >> 8);\n+  x = x + (x >> 16);\n+  return x & m4;\n+}\n+\n+/* { dg-final { scan-tree-dump-times \"\\.POPCOUNT\" 1 \"optimized\" } } */\n+\n+\ndiff --git a/gcc/testsuite/gcc.dg/tree-ssa/popcount9.c b/gcc/testsuite/gcc.dg/tree-ssa/popcount9.c\nnew file mode 100644\nindex 00000000000..4fb08d34984\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/tree-ssa/popcount9.c\n@@ -0,0 +1,22 @@\n+/* { dg-do compile } */\n+/* { dg-require-effective-target popcount } */\n+/* { dg-require-effective-target int32plus } */\n+/* { dg-options \"-O2 -fdump-tree-optimized\" } */\n+\n+const unsigned m1  = 0x55555555UL;\n+const unsigned m2  = 0x33333333UL;\n+const unsigned m3  = 0x0F0F0F0FUL;\n+const unsigned m4  = 0x0000003F;\n+\n+int popc(unsigned x) {\n+  x = x - ((x >> 1) & m1);\n+  x = x - 3*((x >> 2) & m2);\n+  x = (x + (x >> 4)) & m3;\n+  x = x + (x >> 8);\n+  x = x + (x >> 16);\n+  return x & m4;\n+}\n+\n+/* { dg-final { scan-tree-dump-times \"\\.POPCOUNT\" 1 \"optimized\" } } */\n+\n+\n",
    "prefixes": [
        "v2"
    ]
}