Unnamed repository; edit this file 'description' to name the repository.
Rollup merge of #157224 - LiosK:round_char_boundary, r=Mark-Simulacrum
Manually unroll loop in `str::floor_char_boundary` This commit manually unrolls the while loops to at most three iterations, exploiting the UTF-8 invariant that a character is at most four bytes long. Benefits: - Prevents LLVM from generating unbounded unrolled code when `index` is statically known - e.g., `s.floor_char_boundary(20)` previously could emit up to 20 repeated loop bodies. - Eliminates the check at `index - 3`: the UTF-8 invariant guarantees that if `index - 2` is not a character boundary, `index - 3` must be, so the third iteration needs no conditional. - Allows out-of-order CPUs to issue all three byte loads in parallel, since their offsets are statically known. This commit will close rust-lang/rust#149466 with simpler code. The optimizer appears to be able to eliminate bound checks and panic paths.
Jacob Pratt 6 weeks ago
parent 8fff4d5 · parent 5935dd5 · commit fcf8053
0 files changed, 0 insertions, 0 deletions