Use the fact that the number of line break is lower than printable characters to
guide the optimization process. Also use a fuzzy test that catches both \n and
\r in a single check to speedup the computation.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
When running perf stat -e instructions ./bin/clang -O0 -fsyntax-only sqlite3.c -o/dev/null -w before / after the patch, I get:
1,929,024,335 instructions before
1,905,625,961 instructions after
That's roughly a 1% speedup ;-)
Comment Actions
Nice, it would be worth checking to see if something like this (duplicating the ++I) would be faster or if it codegens the same:
while (I < BufLen) {
// Use a fast check to catch both newlines if (LLVM_UNLIKELY(Buf[I] > std::max('\n', '\r'))) { ++I; continue; } other stuff
}
Comment Actions
Same generated assembly:
┌─→movzbl 0x0(%r13,%rbp,1),%ecx │ cmp $0xd,%cl │↑ jbe 61 │ add $0x1,%ebp ├──cmp %rbp,%rbx └──ja 110