From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50CB527FD44 for ; Tue, 16 Sep 2025 16:44:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=63.228.1.57 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758041099; cv=none; b=K4tYIL3WxU7EOnuuHykFPSXPXiOYQypngt/VDhFiGrOhZncKf8MsxNyJh21vX/OFnIpV3wTKFljQNtUxJr/qAsuBxX+sRg81IPmVyR0yG7qR5QGxkT9kDaC46M8qTNsYAUpYfTrCv23SFy1W30yzh8FevRSYVSM5UjpTJukiGbs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758041099; c=relaxed/simple; bh=D2tall9jhpA0uGs+cxpFOp3+qZo3hMqiZOUW1fQYgy4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kUMzdOhyDDm/PsJsRCiewJVIYxFw7Ej3OXSeQm9gF1Zth/XhP43M4AiktoA1mb3I7reUugvWuOzaYWusM8bgQSejMxyJxprX2yfWpJhauaqzQeVcMZuUymbwL0o6FKp+tEwy599Ja2WAL+S8cuVCtXPMNi8yUU5vodLErRhpZlY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org; spf=pass smtp.mailfrom=kernel.crashing.org; arc=none smtp.client-ip=63.228.1.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost [127.0.0.1]) by gate.crashing.org (8.18.1/8.18.1/Debian-2) with ESMTP id 58GGiQU8298843; Tue, 16 Sep 2025 11:44:26 -0500 Received: (from segher@localhost) by gate.crashing.org (8.18.1/8.18.1/Submit) id 58GGiQO0298842; Tue, 16 Sep 2025 11:44:26 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 16 Sep 2025 11:44:26 -0500 From: Segher Boessenkool To: Fangrui Song Cc: Indu Bhagat , Steven Rostedt , Jan Beulich , Rainer Orth , "linux-toolchains@vger.kernel.org" , Jens Remus , Sterling Augustine , Pavel Labath , Andrii Nakryiko , Josh Poimboeuf , Serhei Makarov , Binutils Subject: Re: Unaligned access trade-offs for SFrame FRE layout Message-ID: References: <9d104c46-855c-4b36-8226-1f59b59e455c@suse.com> <26895e7a-5d54-4c89-aeb4-bcd094ba081d@suse.com> <1308e9fa-90c8-4c52-b53d-afd24542b4c8@suse.com> <76b8c89e-5d80-48da-aff1-580d539d1b87@oracle.com> <20250915120742.7ff2f781@gandalf.local.home> Precedence: bulk X-Mailing-List: linux-toolchains@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Sep 16, 2025 at 09:32:30AM -0700, Fangrui Song wrote: > The read32le(p) function is either a standard read or a byte-swapped > read. You should never overcomplicate things by doing byte-swaps. Instead, just say what you mean: u32 read32le(u8 *p) { return p[0] + 0x100*p[1] + 0x10000*p[2] + 0x1000000*p[3]; } or something like that. The compiler can optimise such things just fine! There is no need to go via extra indirections. Segher