a9a437ffc4
As I said already yesterday in another PR, I'm afraid the mixing of apples and oranges (what we are actually computing, whether what bytes are zero or non-zero in the native representation of EXP itself or what EXP points to) in a single function where it performs some handling which must be specific to one or the other case unconditionally and only from time to time determines something based on if nbytes is 0 or not will continue to bite us again and again. So, this patch performs at least a partial cleanup to separate those two cases into two functions. In addition to the separation, the patch uses e.g. ctor_for_folding so that it does handle volatile loads properly and various other checks instead of directly using DECL_INITIAL or does guard native_encode_expr call the way it is guarded elsewhere (that host and target byte sizes are expected). I've left other issues I found as is for now, like the *allnonnul being IMHO wrongly computed (if we don't know anything about the bytes, such as if _1 = MEM[s_2(D)]; MEM[whatever] = _1; where nothing really is known about strlen(s) etc., the code right now clears *nulterm and *allnul, but keeps *allnonnull set), but the callers seem to never use that value for anything (so the question is why is it computed and how exactly should it be defined). Another thing I find quite weird is the distinction between count_nonzero_bytes failing (return false) and when it succeeds, but sets values to a don't know state (the warning is only issued if it succeeds), plus what lenrange[2] is for. The size of the store should be visible already from the store statement. Also the looking at the type of the MEM_REF first operand to determine if it is is_char_store is really weird, because both in user code and through sccvn where pointer conversions are useless the type of the MEM_REF operand doesn't have to have anything to do with what the code actually does. 2020-03-17 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/94015 * tree-ssa-strlen.c (count_nonzero_bytes): Split portions of the function where EXP is address of the bytes being stored rather than the bytes themselves into count_nonzero_bytes_addr. Punt on zero sized MEM_REF. Use VAR_P macro and handle CONST_DECL like VAR_DECLs. Use ctor_for_folding instead of looking at DECL_INITIAL. Punt before calling native_encode_expr if host or target doesn't have 8-bit chars. Formatting fixes. (count_nonzero_bytes_addr): New function. * gcc.dg/pr94015.c: New test. |
||
---|---|---|
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
gotools | ||
include | ||
INSTALL | ||
intl | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcc1 | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgfortran | ||
libgo | ||
libgomp | ||
libhsail-rt | ||
libiberty | ||
libitm | ||
libobjc | ||
liboffloadmic | ||
libphobos | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.dir-locals.el | ||
.gitattributes | ||
.gitignore | ||
ABOUT-NLS | ||
ar-lib | ||
ChangeLog | ||
ChangeLog.jit | ||
ChangeLog.tree-ssa | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING3 | ||
COPYING3.LIB | ||
COPYING.LIB | ||
COPYING.RUNTIME | ||
depcomp | ||
install-sh | ||
libtool-ldflags | ||
libtool.m4 | ||
lt~obsolete.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
multilib.am | ||
README | ||
symlink-tree | ||
test-driver | ||
ylwrap |
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.