From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id D2BD54B20F for ; Fri, 31 May 2024 00:41:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EA9FC68D484; Fri, 31 May 2024 03:41:48 +0300 (EEST) Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 11FCE68D3EB for ; Fri, 31 May 2024 03:41:42 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 35D2940002 for ; Fri, 31 May 2024 00:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1717116101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HWh4WgodKmc0W2WfbkFdZLS3Us56yts4BD+X339VZz4=; b=RUFPIUPC0OmsuM0ysG+jCubnNQXaN++XS8QbWZexk1oONAh+LgYF5Kpa7zr/Q4PASB1f8O EJaGIQ9Jsb03U4qHb6xOLVxOx8HKTvUbQC6tRra7jPI3twdrIYR21GwqELJnCFASwtw9Vz YKSMSnfiaYqnTCZB88zszniXwTYmS8Q7P7r+qjEA9dPP9DknvVwH8Yby7WwgPGoX3pO0+S iadA8n4gtluW5XhxLV0tCfvsDjIxOswkFikP8NhKdHYQIT3HfEBEuWB+BJsZ+hYXC8Z5p0 OKVVNw3kQnCvMn8W8qxUkubG7brhhcgd9hLIZ30jDRfQCEtMAg/SctL4ILvrGA== Date: Fri, 31 May 2024 02:41:40 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20240531004140.GL2821752@pb2> References: <27e5f614496e729f68326a31c3ac70d5923cfa97.camel@haerdin.se> <0c19df65a8142e2cf96fbc07a92bf44bb32f1107.camel@haerdin.se> <14560CCC-A959-44E7-A2E8-764DBE6478C0@remlab.net> MIME-Version: 1.0 In-Reply-To: <14560CCC-A959-44E7-A2E8-764DBE6478C0@remlab.net> X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 4/5] lavu/intmath.h: Fix UB in ff_ctz_c() and ff_ctzll_c() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: multipart/mixed; boundary="===============3407551056395295249==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============3407551056395295249== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="sbU44GGDGzBBUYp9" Content-Disposition: inline --sbU44GGDGzBBUYp9 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 30, 2024 at 10:54:46AM +0300, R=E9mi Denis-Courmont wrote: > Can't we just use the compiler built-ins here? AFAIK, they (GCC, LLVM) us= e the same algorithm if the CPU doesn't support native CTZ. And they will p= ick the right instruction if CPU does have CTZ. >=20 > I get it that maybe it wasn't working so well 20 years ago, but we've inc= reased compiler version requirements since then. ffmpeg is written in C not GNU-C nor LLVM-C so we need to have non buggy C code A modern compiler should turn a built-in into a efficient piece of code but so should it recognize that efficient piece of code and turn it into a single instruction if such exist. In the end with a modern compiler it shouldnt matter how you write this a loop, some optimized standard implementation or a built in the disavantage of a builtin is that it requires #ifs and checks for each compiler. So we should go with the simplest/cleanest that reliably produces optimal c= ode across all supported platforms (and also consider potential future platforms so we dont have a maintaince nightmare but something that we can write once and expect it will be close to optimal forever) Above though is off topic in this thread, which was a bugfix that we need a= nyway (also for backporting) thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Does the universe only have a finite lifespan? No, its going to go on forever, its just that you wont like living in it. -- Hiranya Peiri --sbU44GGDGzBBUYp9 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZlkcwwAKCRBhHseHBAsP q3jfAKCS9+69KaIZstIjoADP3SbHeqQSggCglN/aUEhODhfTvzDwUd+MVF905tg= =fxDe -----END PGP SIGNATURE----- --sbU44GGDGzBBUYp9-- --===============3407551056395295249== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============3407551056395295249==--