From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2070.outbound.protection.outlook.com [40.107.20.70]) by sourceware.org (Postfix) with ESMTPS id 834A63858D32 for ; Mon, 16 Jan 2023 14:03:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 834A63858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HgdXWnvVg1lwamH9BMNeXwH0lBpra62HzJ+Mlu4IcLU=; b=D+OS9235B79WP9z1+L/BbsLjoI4CG7GsHjAaSSCSeFbsha6AFa/FYDLw19Ri7uU/kXUaOwqqPIqttmVlk8wcGCLwLaCkbsCkIT1EIxOAq6yGrQ+KpbLxOToq6kO3wTb/sBmjR0lo+yXdbl6Cpqg8182FB7cCyDY4EDASbUNqm/0= Received: from DB6P195CA0007.EURP195.PROD.OUTLOOK.COM (2603:10a6:4:cb::17) by DB9PR08MB9754.eurprd08.prod.outlook.com (2603:10a6:10:45d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Mon, 16 Jan 2023 14:03:40 +0000 Received: from DBAEUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:cb:cafe::8a) by DB6P195CA0007.outlook.office365.com (2603:10a6:4:cb::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Mon, 16 Jan 2023 14:03:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT041.mail.protection.outlook.com (100.127.142.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Mon, 16 Jan 2023 14:03:40 +0000 Received: ("Tessian outbound 0d7b2ab0f13d:v132"); Mon, 16 Jan 2023 14:03:40 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ba3375df998a1b35 X-CR-MTA-TID: 64aa7808 Received: from 0907fecbd361.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C4DF09C1-4514-458F-AD13-3DE187E3A84E.1; Mon, 16 Jan 2023 14:03:34 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0907fecbd361.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 16 Jan 2023 14:03:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QzrNuVjTiAsAqRCFyt/pijdxXiYWSqEIAuNtuU5nBfylq1AlmWzDPDCuURu7r4rtgRo/7QyIgPKea7BNiDVw+II5mOLhHuGo6vuOjqgVnOCmoqKGAlJdIqomWQnsDdUC8fwxt0kbP/pzJP/8VDW5vkStbZpbFGCk5ztwFhLcV8Bz7yyuVvajtnMXjoireJfTnxCvHf3ed2N3h5TlgmLtqum7RTWBmXuA02ZnF8iAhHP/FYt3LaJL2u9xlbzMUMrl4kctvNOUnqPQ5sJ7Mg1M+CFn/2ZK32lrgfa+z6V83Ew+Bb1vOIHMWGpHZNHVrBxbNt4XADf4eoRXgQVdREX51Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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; bh=HgdXWnvVg1lwamH9BMNeXwH0lBpra62HzJ+Mlu4IcLU=; b=RfjKyAFXUkynrFGWamBj5DKpcsVEZTZTbzGdnSCPaBXYXtEJCnwHuznlCtF62tgQois1eBLegazJvIW7qXcacGFhzOPN/6tPLU4zwM2RcnLPBzGNiLFs6pSqoUN9SQpe40OajwkX3CeX0E95B3/T5YI1bT+MPij7FHjsivXe/esHHc5aDfZWHAimvYepR05mHtmx+48qqe6OFRUzn0gcy1WFAMBxJ2Q6sISPFnRt1KhXqcMc2cXWIAsfidLmUhGIoL+Xzk3MjMB7I+QITqWyaroLccp1kA+irStG1w8NaTAJXsJVjKr6i9HSUxoDPKsn039bTRNkCAKv0a67HG9NZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HgdXWnvVg1lwamH9BMNeXwH0lBpra62HzJ+Mlu4IcLU=; b=D+OS9235B79WP9z1+L/BbsLjoI4CG7GsHjAaSSCSeFbsha6AFa/FYDLw19Ri7uU/kXUaOwqqPIqttmVlk8wcGCLwLaCkbsCkIT1EIxOAq6yGrQ+KpbLxOToq6kO3wTb/sBmjR0lo+yXdbl6Cpqg8182FB7cCyDY4EDASbUNqm/0= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) by PA4PR08MB7641.eurprd08.prod.outlook.com (2603:10a6:102:273::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Mon, 16 Jan 2023 14:03:32 +0000 Received: from AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::8256:29ca:bcd8:b754]) by AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::8256:29ca:bcd8:b754%5]) with mapi id 15.20.5986.023; Mon, 16 Jan 2023 14:03:32 +0000 Date: Mon, 16 Jan 2023 14:03:29 +0000 From: Andrew Carlotti To: gcc-patches@gcc.gnu.org Cc: Richard Biener Subject: Re: [PATCH 9/8] middle-end: Allow build_popcount_expr to use an IFN Message-ID: References: Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: LO2P265CA0330.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a4::30) To AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6678:EE_|PA4PR08MB7641:EE_|DBAEUR03FT041:EE_|DB9PR08MB9754:EE_ X-MS-Office365-Filtering-Correlation-Id: 503241af-769d-4238-d58f-08daf7ca789b x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: egTkdmOtq2nXAiUneKjg0Urz8pYonU9dWxB9+lvgNzM/lefyX+SNIU0j/a9Fw2iETbC2mlxhyBjPQebfVKs5Qx7lgabgOaUbcP9ToKXTpbxSSKrAz96C3VgQmt0apQvBy0FpnPsuzwCowS+hZXeg7IGYEpWW9d39AEeKf/WT7gbQ83+5xWUqvpTQwIokzOhTZ3JFBqdJ/nDPd9Lb0liPMq2joRlIuLM1h3//RToxDS7A0w9xbMSaxEXR0KVr1DnfrJCWf0mVVP1Z4nLSE+Kxu9crh/Jc8fAIQYn7PEvkQNLusv2iKM90LrfGW2TPBIfNYlRPKWmgwgOyRlQfa6DOqzz5mR4NVYss3fzlRMUo35x5hHDlkIgvWyPh8LmrHPhNmiuLvN1Em/DwWZR5A3eF8ZtCpuytAvfWQ4Ox09+UfhmM38WnzfSXvAJdPxu3HGeNrzKLBI+E4JCFIO7SD3stYp8b72hmI6iw4P0PXZ6228PWuxOgPxJEFIAfwc5habIJFFuQDHL+a3EV6HVx81nIGHqwgYjiBufmlbadLVcLCt7qB7w7dABuD1U+MF/B6aOrjVjC9x8CfZDiUWT7tjMr05I8DR0+uRyyE7BxaNwce/TVDxug17dKbc8GQIQpHPtiROCDTDCZDqDlNii1WRTH1hgLJ9fms6LGWiR9n3RO6BraSFs5CaGOuPUlVvgmImMlrK+/riW458o5MBG0ZdqJkw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR08MB6678.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(396003)(366004)(136003)(39860400002)(451199015)(316002)(41300700001)(66476007)(66556008)(66946007)(4326008)(2906002)(6916009)(8676002)(8936002)(5660300002)(44832011)(6486002)(86362001)(26005)(186003)(478600001)(6512007)(6666004)(6506007)(38100700002)(84970400001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB7641 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1990fcf0-e584-4a4a-caae-08daf7ca733d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: id8zYiHGLPtrcTYcpf0IDFfptV0VFgcjlxTLizwQKu9+kb1GWWdF3fMF4km02CJT6zlJYAC4CIy5arh0CzVUhaS4pFepigA1dx5EcXTogG6QWZlXP3GDZlpccWlr8yIv5ucByvCeBAVAY73R8B2tyUes0eR2/PisMz2T7UMpw6BeJmy22njMyNDPccZwwc3rjc2IFo4pUGMytuP3noIkJwChBdt485NyG0h4hZxjgAzSG+bFcAmEcWKZg2mbypASf69nFM10O9qbJ53hJVY0n/4BMSsbc4KHak1GgaiodJZrApYpCNgRwQo/yNSqddlOQ9mE+AgjTECJCUNPpb5tLF93XSmunKoS2SIWSxEieS+MTT6t1w7gLaH4+i6Riyw0DW02GqiFAdSfPvaNP4CSabxyyun/onTYQfvdSEDJDVwy7qil3MjCBOJp/0eyhfeHwGewtis3TjB3l0kNB1jJy9VxxOVqLyuGKtSbkJvn+atOlIkWPL/w1K8COOKsUbk6ywr2MmL/Yk6uQemgtVrxtJ0a0fy9xp0DBqWVpBEtq7j20otAo9QyWplLu2ugGTnXMKTcHKWEXQ2kx7NTwh6Vvdkwdy1G42dBysj6toG6XC6t3IUxzRcQhIRL2PK2tp9ov4DkHOdxNqRF0tlCFm8BO2gl5BFLrYrw6lHOl305jgkxfEKjOuufktrebILtzwJT8kbKWcKIm2DGi6qGESl2WltOyDsSijZm1V0YfL50W4RULvOiRPto3/8coUmVM5BtKw8LMyQU8jmDvm+8q5ySPQ== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(39860400002)(396003)(136003)(451199015)(36840700001)(46966006)(40470700004)(82740400003)(70206006)(70586007)(4326008)(6916009)(8676002)(316002)(81166007)(336012)(47076005)(82310400005)(356005)(36860700001)(40460700003)(478600001)(6486002)(6512007)(26005)(41300700001)(6506007)(186003)(86362001)(40480700001)(6666004)(107886003)(5660300002)(44832011)(2906002)(84970400001)(8936002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2023 14:03:40.5123 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 503241af-769d-4238-d58f-08daf7ca789b X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB9754 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,KAM_LOTSOFHASH,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Richard I accidentally pushed this patch earlier in the mistaken belief that you'd already approved it. It looks uncontroversial to me - it just adds IFN support to build_popcount_expr, analogous to the changes you suggested and approved for build_cltz_expr (and adjusts testcases accordingly). I might have incorporated it into an earlier patch in this series, if I hadn't already pushed that earlier patch. Is this OK to leave in master now? Thanks, Andrew On Thu, Dec 22, 2022 at 05:43:21PM +0000, Andrew Carlotti via Gcc-patches wrote: > Bootstrapped and regression tested on aarch64-unknown-linux-gnu and > x86_64-pc-linux-gnu - ok to merge? > > gcc/ChangeLog: > > * tree-ssa-loop-niter.cc (build_popcount_expr): Add IFN support. > > gcc/testsuite/ChangeLog: > > * g++.dg/tree-ssa/pr86544.C: Add .POPCOUNT to tree scan regex. > * gcc.dg/tree-ssa/popcount.c: Likewise. > * gcc.dg/tree-ssa/popcount2.c: Likewise. > * gcc.dg/tree-ssa/popcount3.c: Likewise. > * gcc.target/aarch64/popcount4.c: Likewise. > * gcc.target/i386/pr95771.c: Likewise, and... > * gcc.target/i386/pr95771-2.c: ...split int128 test from above, > since this would emit just a single IFN if a TI optab is added. > > --- > > diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr86544.C b/gcc/testsuite/g++.dg/tree-ssa/pr86544.C > index ef438916a8019320564f444ace08e2f4b4190684..50befb36bac75de1cfa282e38358278b3288bd1c 100644 > --- a/gcc/testsuite/g++.dg/tree-ssa/pr86544.C > +++ b/gcc/testsuite/g++.dg/tree-ssa/pr86544.C > @@ -12,5 +12,5 @@ int PopCount (long b) { > return c; > } > > -/* { dg-final { scan-tree-dump-times "__builtin_popcount" 1 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times "__builtin_popcount|\\.POPCOUNT" 1 "optimized" } } */ > /* { dg-final { scan-tree-dump-times "if" 0 "phiopt4" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/popcount.c b/gcc/testsuite/gcc.dg/tree-ssa/popcount.c > index b4694109411a4631697463519acbe7d9df65bf6e..efd906a0f5447f0beb3752eded3756999b02e6e6 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/popcount.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/popcount.c > @@ -39,4 +39,4 @@ void PopCount3 (long b1) { > } > } > > -/* { dg-final { scan-tree-dump-times "__builtin_popcount" 3 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times "__builtin_popcount|\\.POPCOUNT" 3 "optimized" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/popcount2.c b/gcc/testsuite/gcc.dg/tree-ssa/popcount2.c > index ef73e345573de721833e98e89c252640a55f7c60..ae38a329bd4d868a762300d3218d68864c0fc4be 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/popcount2.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/popcount2.c > @@ -26,4 +26,4 @@ int main() > return 0; > } > > -/* { dg-final { scan-tree-dump-times "__builtin_popcount" 1 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times "__builtin_popcount|\\.POPCOUNT" 1 "optimized" } } */ > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/popcount3.c b/gcc/testsuite/gcc.dg/tree-ssa/popcount3.c > index ef438916a8019320564f444ace08e2f4b4190684..50befb36bac75de1cfa282e38358278b3288bd1c 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/popcount3.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/popcount3.c > @@ -12,5 +12,5 @@ int PopCount (long b) { > return c; > } > > -/* { dg-final { scan-tree-dump-times "__builtin_popcount" 1 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times "__builtin_popcount|\\.POPCOUNT" 1 "optimized" } } */ > /* { dg-final { scan-tree-dump-times "if" 0 "phiopt4" } } */ > diff --git a/gcc/testsuite/gcc.target/aarch64/popcount4.c b/gcc/testsuite/gcc.target/aarch64/popcount4.c > index ee55b2e335223053ca024e95b7a13aa4af32550e..8aa15ff018d4b5fc6bb59e52af20d5c33cea2ee0 100644 > --- a/gcc/testsuite/gcc.target/aarch64/popcount4.c > +++ b/gcc/testsuite/gcc.target/aarch64/popcount4.c > @@ -11,4 +11,4 @@ int PopCount (long b) { > return c; > } > > -/* { dg-final { scan-tree-dump-times "__builtin_popcount" 0 "optimized" } } */ > +/* { dg-final { scan-tree-dump-times "__builtin_popcount|\\.POPCOUNT" 0 "optimized" } } */ > diff --git a/gcc/testsuite/gcc.target/i386/pr95771-2.c b/gcc/testsuite/gcc.target/i386/pr95771-2.c > new file mode 100644 > index 0000000000000000000000000000000000000000..1db9dc94d0b66477667624012221d6844c141a26 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/pr95771-2.c > @@ -0,0 +1,17 @@ > +/* PR tree-optimization/95771 */ > +/* { dg-do compile } */ > +/* { dg-require-effective-target int128 } */ > +/* { dg-options "-O2 -mpopcnt -fdump-tree-optimized" } */ > +/* { dg-final { scan-tree-dump " = __builtin_popcount| = \\.POPCOUNT" "optimized" } } */ > + > +int > +corge (unsigned __int128 x) > +{ > + int i = 0; > + while (x) > + { > + x &= x - 1; > + ++i; > + } > + return i; > +} > diff --git a/gcc/testsuite/gcc.target/i386/pr95771.c b/gcc/testsuite/gcc.target/i386/pr95771.c > index d7b67017800b705b9854f561916c20901ea76803..d41be445f4a68613a082b8956fea3ceaf33d7e0f 100644 > --- a/gcc/testsuite/gcc.target/i386/pr95771.c > +++ b/gcc/testsuite/gcc.target/i386/pr95771.c > @@ -1,8 +1,7 @@ > /* PR tree-optimization/95771 */ > /* { dg-do compile } */ > /* { dg-options "-O2 -mpopcnt -fdump-tree-optimized" } */ > -/* { dg-final { scan-tree-dump-times " = __builtin_popcount" 6 "optimized" { target int128 } } } */ > -/* { dg-final { scan-tree-dump-times " = __builtin_popcount" 4 "optimized" { target { ! int128 } } } } */ > +/* { dg-final { scan-tree-dump-times " = __builtin_popcount| = \\.POPCOUNT" 4 "optimized" } } */ > > int > foo (unsigned char x) > @@ -51,17 +50,3 @@ qux (unsigned long long x) > } > return i; > } > - > -#ifdef __SIZEOF_INT128__ > -int > -corge (unsigned __int128 x) > -{ > - int i = 0; > - while (x) > - { > - x &= x - 1; > - ++i; > - } > - return i; > -} > -#endif > diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc > index 9c2f9f3d5f6205bb5e7f490257800c660fdd0b8d..cc53b27329f8518bc2cacef1830768a140331b31 100644 > --- a/gcc/tree-ssa-loop-niter.cc > +++ b/gcc/tree-ssa-loop-niter.cc > @@ -2033,11 +2033,18 @@ static tree > build_popcount_expr (tree src) > { > tree fn; > + bool use_ifn = false; > int prec = TYPE_PRECISION (TREE_TYPE (src)); > int i_prec = TYPE_PRECISION (integer_type_node); > int li_prec = TYPE_PRECISION (long_integer_type_node); > int lli_prec = TYPE_PRECISION (long_long_integer_type_node); > - if (prec <= i_prec) > + > + tree utype = unsigned_type_for (TREE_TYPE (src)); > + src = fold_convert (utype, src); > + > + if (direct_internal_fn_supported_p (IFN_POPCOUNT, utype, OPTIMIZE_FOR_BOTH)) > + use_ifn = true; > + else if (prec <= i_prec) > fn = builtin_decl_implicit (BUILT_IN_POPCOUNT); > else if (prec == li_prec) > fn = builtin_decl_implicit (BUILT_IN_POPCOUNTL); > @@ -2046,12 +2053,11 @@ build_popcount_expr (tree src) > else > return NULL_TREE; > > - tree utype = unsigned_type_for (TREE_TYPE (src)); > - src = fold_convert (utype, src); > - if (prec < i_prec) > - src = fold_convert (unsigned_type_node, src); > tree call; > - if (prec == 2 * lli_prec) > + if (use_ifn) > + call = build_call_expr_internal_loc (UNKNOWN_LOCATION, IFN_POPCOUNT, > + integer_type_node, 1, src); > + else if (prec == 2 * lli_prec) > { > tree src1 = fold_convert (long_long_unsigned_type_node, > fold_build2 (RSHIFT_EXPR, TREE_TYPE (src), > @@ -2064,7 +2070,12 @@ build_popcount_expr (tree src) > call = fold_build2 (PLUS_EXPR, integer_type_node, call1, call2); > } > else > - call = build_call_expr (fn, 1, src); > + { > + if (prec < i_prec) > + src = fold_convert (unsigned_type_node, src); > + > + call = build_call_expr (fn, 1, src); > + } > > return call; > }