From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B44F03858D28 for ; Sat, 16 Dec 2023 08:36:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B44F03858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B44F03858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702715784; cv=none; b=N4jwB3ZbZmKRrLteAG7VcC4mI39CvUm9jo/qJHvl1F08mv15WAhiCvQIh+OQtzVujHbA0tQ9fsjqM4CfNAMRS3jFrFLk5/v8jvLQNjogzT20HrtU/d7jnlUaBgmErBlR6ENPiCxUy8tsNf99yF3tRwq7pxvRbcB9npjkk2pwFS0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702715784; c=relaxed/simple; bh=sYYAgw/uG8TytB19vF0hQuKA+Apx/ZOLckLBcSsKntk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=GIqZWMdv2pvujSyADCvIqelVOmVfEu78KGcwtlIBFqleIeLvKN3hLMx54Pk0NJZeRyFR3MUGhMcrzeJ8KH2hHEJgHPYAKtEmZCtQ87EuNnvUp2ZePbs2EVDP6vbhmuvOi94aL4ozceCUNYA10w8sO6UemGDSKpMN0q+tE+7kSog= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702715782; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=H6EZAYNL2b5JUcjAZo5NMeR+kv2w/Nf+Ha24GVldFXw=; b=crcXXDYX83wwe87u8iixLPwSIuuDQazhlUQ0xqxe5HfJeTXZV88Xn/Ayxm1stk8CLck+Yt VOKjtlob4IzJXkOok2CAB5Ygn7V9lbWTD2R+D/9P/CLbEQpU50+ylMkghjnsrUCfU6ExPR qGZc7U0NGQLbML2EyKkbAZb2Migmqy0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-551-FnBIfXxMPYOIAqokI6xbvw-1; Sat, 16 Dec 2023 03:36:18 -0500 X-MC-Unique: FnBIfXxMPYOIAqokI6xbvw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 66ED480B633; Sat, 16 Dec 2023 08:36:18 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EE87F1121306; Sat, 16 Dec 2023 08:36:17 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3BG8aFVD1624161 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 16 Dec 2023 09:36:15 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3BG8aDP21624160; Sat, 16 Dec 2023 09:36:13 +0100 Date: Sat, 16 Dec 2023 09:36:13 +0100 From: Jakub Jelinek To: Andrew Pinski Cc: "Joseph S. Myers" , Richard Biener , Jason Merrill , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Add type-generic clz/ctz/clrsb/ffs/parity/popcount builtins [PR111309] Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: On Fri, Dec 15, 2023 at 09:51:10PM -0800, Andrew Pinski wrote: > I was looking into improving __builtin_popcountg for __int128 on > aarch64 (when CSSC is not implemented which right now is almost all > cores) but this patch forces __builtin_popcountg to expand into 2 > __builtin_popcountll (and add) before it could optimize into an > internal function for the popcount and have the backend a possibility > of using implementing something better. > This is due to the code in fold_builtin_bit_query, what might be the > best way of disabling that for this case? > > Basically right now popcount is implemented using the SIMD instruction > cnt which can be used either 8x1 or 16x1 wide. Using the 16x1 improves > both the code size and performance (on almost all cores I know of). So > instead of 2 cnt instructions, we only would need one. The reason for lowering those 2 * wordsize cases early is that there is no __builtin_{clz,ctz,clrsb,ffs,parity,popcount}* for those cases (so we can't expect expansion to say libgcc routines as fallback) and IFN_{CLZ,CTZ,CLRSB,FFS,PARITY,POPCOUNT} are still direct optab ifns (now with the extension that large/huge _BitInt is ok for those as operands because we are guaranteed to lower that during bitint lowering). Anything else won't make it through the direct optab checks and won't be guaranteed to expand. You can always define optabs for those and handle them in md files if it results in better code. Jakub