diff options
author | Alexander Monakov <amonakov@ispras.ru> | 2024-08-06 09:47:23 +0300 |
---|---|---|
committer | Alexander Monakov <amonakov@ispras.ru> | 2024-08-20 14:09:12 +0300 |
commit | 20a5b4824993ae1c99f3b965c5e07bbd2c64b2ce (patch) | |
tree | a70a1417e98d486c41ba2be23b9da4cbfc2b1b45 /libcpp/files.cc | |
parent | b8ea13ebf1211714503fd72f25c04376483bfa53 (diff) | |
download | gcc-20a5b4824993ae1c99f3b965c5e07bbd2c64b2ce.zip gcc-20a5b4824993ae1c99f3b965c5e07bbd2c64b2ce.tar.gz gcc-20a5b4824993ae1c99f3b965c5e07bbd2c64b2ce.tar.bz2 |
libcpp: replace SSE4.2 helper with an SSSE3 one
Since the characters we are searching for (CR, LF, '\', '?') all have
distinct ASCII codes mod 16, PSHUFB can help match them all at once.
Directly use the new helper if __SSSE3__ is defined. It makes the other
helpers unused, so mark them inline to prevent warnings.
Rewrite and simplify init_vectorized_lexer.
libcpp/ChangeLog:
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Check for SSSE3 instead of SSE4.2.
* files.cc (read_file_guts): Bump padding to 64 if HAVE_SSSE3.
* lex.cc (search_line_acc_char): Mark inline, not "unused".
(search_line_sse2): Mark inline.
(search_line_sse42): Replace with...
(search_line_ssse3): ... this new function. Adjust the use...
(init_vectorized_lexer): ... here. Simplify.
Diffstat (limited to 'libcpp/files.cc')
-rw-r--r-- | libcpp/files.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libcpp/files.cc b/libcpp/files.cc index 78f56e3..3775091 100644 --- a/libcpp/files.cc +++ b/libcpp/files.cc @@ -693,7 +693,7 @@ static bool read_file_guts (cpp_reader *pfile, _cpp_file *file, location_t loc, const char *input_charset) { - ssize_t size, total, count; + ssize_t size, pad, total, count; uchar *buf; bool regular; @@ -732,11 +732,14 @@ read_file_guts (cpp_reader *pfile, _cpp_file *file, location_t loc, the majority of C source files. */ size = 8 * 1024; - /* The + 16 here is space for the final '\n' and 15 bytes of padding, - used to quiet warnings from valgrind or Address Sanitizer, when the - optimized lexer accesses aligned 16-byte memory chunks, including - the bytes after the malloced, area, and stops lexing on '\n'. */ - buf = XNEWVEC (uchar, size + 16); +#ifdef HAVE_SSSE3 + pad = 64; +#else + pad = 16; +#endif + /* The '+ PAD' here is space for the final '\n' and PAD-1 bytes of padding, + allowing search_line_fast to use (possibly misaligned) vector loads. */ + buf = XNEWVEC (uchar, size + pad); total = 0; while ((count = read (file->fd, buf + total, size - total)) > 0) { @@ -747,7 +750,7 @@ read_file_guts (cpp_reader *pfile, _cpp_file *file, location_t loc, if (regular) break; size *= 2; - buf = XRESIZEVEC (uchar, buf, size + 16); + buf = XRESIZEVEC (uchar, buf, size + pad); } } @@ -765,7 +768,7 @@ read_file_guts (cpp_reader *pfile, _cpp_file *file, location_t loc, file->buffer = _cpp_convert_input (pfile, input_charset, - buf, size + 16, total, + buf, size + pad, total, &file->buffer_start, &file->st.st_size); file->buffer_valid = file->buffer; |