From nobody Mon Jul 10 19:56:19 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4R0FBF09Dxz2tlws; Mon, 10 Jul 2023 19:56:21 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4R0FBD6rnyz4FkZ; Mon, 10 Jul 2023 19:56:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689018981; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o7e/DF8IEctvH3RSAHXs8DWm7MyHz0WbsHWJL15bHEA=; b=SKeWHD7Gy4BsA52Vwt3aZ4LSZMsDA9mWxl5gvuHV4Gu0tD8SHX2qC/mwVaYC852MuAzqpk U3IVr0ypVUtvdxGK4U6kot1M0ftr6plRlENiTbxvCESN7QI38FELwU8vB5ZlX4lahMZRJQ iEDX4zlyD7pe7iFt/Q8qAJdyYoZngcmXkJXTtQTbXmkNw2X8SKi9BUW3rstMX3+gxiF1ZJ qKMI4wHUMjKA10ETXAmbwJZhYUAlA4Ke1rirIyhM8mBz7sI6P5yLTDQno+nYEE4/GPUd3T NTxiLMFHtZSIJvl9VNx3fjqhOX8bs+S87r1SNmZEY7yqs3yNdI2R9mjwA6RecA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689018981; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o7e/DF8IEctvH3RSAHXs8DWm7MyHz0WbsHWJL15bHEA=; b=nQ6QffjcXP28FSaxpP11v+zjNuPRfTmruCoCOZy4YxPKtnYUfShwHNGKqqia+C1+pqOC0x LlGYKqkZxyDeY8byaricrDqmKd3yAksSfguSM88HdTJJPD3Lpf74LFyc4ECwXFil2d5Vbd LxjhgpZIpQqqT7yYpl38CGgP9nQnFrRhh/984hqpqgPl2N74nGOh6zSxzYuHUYds2eVVmV lNT7uChfBUn8fJQgkokoWgFhVDS8GTTDNUO6C/PcW1YzsfEi6htILyPJ90iLnFJdu9CwKH /w305fFcwwAaREBmiA0ZFoVtHfh1sf2syV45EIQl33SyzENahl0mpXrWWzrXcw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689018981; a=rsa-sha256; cv=none; b=szvg5j3bXvxCE3OnfdgrKqUqTsVrnKfQr+VgC2d02jmmO1qO8u69ZnzuLBqY1LV0p64Jp5 mqJKjSxvOJs1mIek5nP+qgZpFR83B7T8oWFHV+FEb66GQvRgBHNJvKqgwWY3auFWzT3+jh qXDsU1Ka1a6/fdRTl5KqpvdwG4J+VhMsqqpw3oLoYp8+wK8dC5SJIpHueuD/uMlV02EI4A JBaPJaMvGZk6/So2pDJvr1D7/CDcc35cpWlN6gGUMZbiQv7aVOG3uGxxvGtvq2s/AzbIEx KalvVmUveoDhrTlvuaWtppvOi9XjLk2+NJ5RVHPW49DoraKh/K8/WWgOVQzS/A== Received: from [IPV6:2601:648:8680:16b0:6966:ae6d:9848:4b0b] (unknown [IPv6:2601:648:8680:16b0:6966:ae6d:9848:4b0b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4R0FBD2s08z1HFf; Mon, 10 Jul 2023 19:56:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Mon, 10 Jul 2023 12:56:19 -0700 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Content-Language: en-US To: Robert Clausecker , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202307032023.363KNhu6031914@gitrepo.freebsd.org> From: John Baldwin Subject: Re: git: ee8b0c436d72 - main - lib/libc/string: replace ffs/fls implementations with clang builtins In-Reply-To: <202307032023.363KNhu6031914@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ThisMailContainsUnwantedMimeParts: N On 7/3/23 1:23 PM, Robert Clausecker wrote: > The branch main has been updated by fuz: > > URL: https://cgit.FreeBSD.org/src/commit/?id=ee8b0c436d7221c25e8be3c3fe1f9da78b9d5b16 > > commit ee8b0c436d7221c25e8be3c3fe1f9da78b9d5b16 > Author: Robert Clausecker > AuthorDate: 2023-06-23 16:22:54 +0000 > Commit: Robert Clausecker > CommitDate: 2023-07-03 20:18:27 +0000 > > lib/libc/string: replace ffs/fls implementations with clang builtins > > Most architectures we support (except for riscv64) have instructions > to compute these functions very quickly. Replace old code with the > ffs and clz builtin functions, allowing clang to generate good code > for all architectures. > > As a consequence, toss out arm and i386 ffs() implementations. > > Sponsored by: FreeBSD Foundation > Approved by: mhorne > MFC after: 1 week > Differential Revision: https://reviews.freebsd.org/D40730 > --- > lib/libc/arm/string/Makefile.inc | 1 - > lib/libc/arm/string/ffs.S | 57 --------------------------------------- > lib/libc/i386/string/Makefile.inc | 1 - > lib/libc/i386/string/ffs.S | 56 -------------------------------------- > lib/libc/string/ffs.c | 12 ++++----- > lib/libc/string/ffsl.c | 12 ++++----- > lib/libc/string/ffsll.c | 12 ++++----- > lib/libc/string/fls.c | 13 +++++---- > lib/libc/string/flsl.c | 14 +++++----- > lib/libc/string/flsll.c | 13 +++++---- > 10 files changed, 34 insertions(+), 157 deletions(-) > > diff --git a/lib/libc/string/ffs.c b/lib/libc/string/ffs.c > index 738ef90ce091..c011b3390612 100644 > --- a/lib/libc/string/ffs.c > +++ b/lib/libc/string/ffs.c > @@ -3,6 +3,10 @@ > * > * Copyright (c) 1990, 1993 > * The Regents of the University of California. All rights reserved. > + * Copyright (c) 2023 The FreeBSD Foundation > + * > + * Portions of this software were developed by Robert Clausecker > + * under sponsorship from the FreeBSD Foundation. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > @@ -43,11 +47,5 @@ __FBSDID("$FreeBSD$"); > int > ffs(int mask) > { > - int bit; > - > - if (mask == 0) > - return(0); > - for (bit = 1; !(mask & 1); bit++) > - mask = (unsigned int)mask >> 1; > - return (bit); > + return (__builtin_ffs(mask)); This breaks the build on GCC: /usr/home/john/work/freebsd/main/lib/libc/string/ffs.c: In function 'ffs': /usr/home/john/work/freebsd/main/lib/libc/string/ffs.c:48:1: error: infinite recursion detected [-Werror=infinite-recursion] 48 | ffs(int mask) | ^~~ /usr/home/john/work/freebsd/main/lib/libc/string/ffs.c:50:17: note: recursive call 50 | return (__builtin_ffs(mask)); | ~^~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors *** Error code 1 -- John Baldwin