Messages in this thread | | | Date | Wed, 13 Jul 2022 12:57:52 +0300 | Subject | Re: [PATCH 2/2] lib/string.c: Optimize memchr() | From | Andrey Semashev <> |
| |
On 7/13/22 12:39, David Laight wrote: > From: Yu-Jen Chang >> Sent: 12 July 2022 15:59 > ... >>> I think you're missing the point. Loads at unaligned addresses may not >>> be allowed by hardware using conventional load instructions or may be >>> inefficient. Given that this memchr implementation is used as a fallback >>> when no hardware-specific version is available, you should be >>> conservative wrt. hardware capabilities and behavior. You should >>> probably have a pre-alignment loop. >> >> Got it. I add pre-alignment loop. It aligns the address to 8 or 4bytes. > > That should be predicated on !HAS_EFFICIENT_UNALIGNED_ACCESS.
If there is a pre-alignment loop, there won't be unaligned loads, so there shouldn't be the need for the HAS_EFFICIENT_UNALIGNED_ACCESS check. Unless I misunderstand what HAS_EFFICIENT_UNALIGNED_ACCESS indicates.
| |