From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ECDC3C87FCB for ; Mon, 4 Aug 2025 15:11:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9341E10E587; Mon, 4 Aug 2025 15:11:37 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="Xfepz9Z0"; dkim-atps=neutral Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id DC14610E587 for ; Mon, 4 Aug 2025 15:11:35 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 988D9419A6; Mon, 4 Aug 2025 15:11:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDA21C4CEE7; Mon, 4 Aug 2025 15:11:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754320295; bh=WsBZ9IWDi4AHnAaDyJYEnE0j2P2HYEAvJGAl8zo5e4U=; h=Date:To:Cc:Subject:From:References:In-Reply-To:From; b=Xfepz9Z0LMoO19prxl1RC/Qhu/HzpwiQPHzWUOiHzdOPniAJPeu1Z2ZrSV3x5Hvxa Dv+QpoXahJ9MpZuLE4JkLoYP3QEgQJCA0ys2/JxrNwZmFYg03ko/bAGL6I6HbwGXEn S9rBu4eRISHBSAfOlLF+vOxSGN4T/L7HBDqqvtimCs/v7lNixsdjMIJTzvM0pCJTrL 3YsNKAyLF0QfAscolFq5rbsMtby16OYnhrQnOLV0jcuY0xowjan+bDoRiEkoVBu/qa eY95FuuEnmUb9JLo+RIlJF6cUhkKxIi+9voLv9lMFoiGvw3v0mX74o/d3X12+UcERy V4A8RWhbf8qmw== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 04 Aug 2025 17:11:30 +0200 Message-Id: To: "Miguel Ojeda" , "Alexandre Courbot" Cc: "Miguel Ojeda" , "Alex Gaynor" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Danilo Krummrich" , , , Subject: Re: [PATCH v2 2/4] rust: add `Alignment` type From: "Benno Lossin" X-Mailer: aerc 0.20.1 References: <20250804-num-v2-0-a96b9ca6eb02@nvidia.com> <20250804-num-v2-2-a96b9ca6eb02@nvidia.com> In-Reply-To: X-BeenThere: nouveau@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Nouveau development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: nouveau-bounces@lists.freedesktop.org Sender: "Nouveau" On Mon Aug 4, 2025 at 4:17 PM CEST, Miguel Ojeda wrote: > On Mon, Aug 4, 2025 at 1:45=E2=80=AFPM Alexandre Courbot wrote: >> + if !self.0.is_power_of_two() { >> + // SAFETY: per the invariants, `self.0` is always a power o= f two so this block will >> + // never be reached. >> + unsafe { core::hint::unreachable_unchecked() } >> + } > > I guess this one is here to help optimize users after they inline the > cal? Is there a particular case you noticed? i.e. it may be worth > mentioning it. I suggested this in the previous version [1]. For example, it optimizes division to only be a left shift. [1]: https://lore.kernel.org/all/DBL1ZGZCSJF3.29HNS9BSN89C6@kernel.org --- Cheers, Benno