Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #50398 - llogiq:memchr-nano-opt, r=nagisa
nano-optimization for memchr::repeat_byte This replaces the multiple shifts & bitwise or with a single multiplication In my benchmarks this performs equally well or better, especially on 64bit systems (it shaves a stable nanosecond on my skylake). This may go against conventional wisdom, but the shifts and bitwise ors cannot be pipelined because of hard data dependencies. While it may or may not be worthwile from an optimization standpoint, it also reduces code size, so there's basically no downside.
- Loading branch information
I'm really curious whether the compiler is smart enough to never ever execute this division as this would really suck for e.g. MCUs without hardware divisor.