Go to file
Jakub Jelinek 74e6a40335 match.pd: Fix up __builtin_mul_overflow_p signed type optimization [PR105984]
Earlier in the simplification pattern, we require that @0 has compatible
type to the type of IMAGPART_EXPR, but for @1 which is a non-zero constant
all we require is that it the constant fits into that type.
Later the code checks if the constant is negative, because when min / max
values are divided by negative divisor, lo will be higher than hi.
In the following testcase, @1 has unsigned char type, while @0 has
int type, so @1 which is 254 is wi::neg_p and we were swapping lo and hi,
even when @1 cast to int isn't negative.

We could use tree_int_cst_sgn (@1) < 0 as the check instead and it would
work both for narrower types of @1 and even same or wider ones, but
I've noticed we probably don't want to call fold_convert (TREE_TYPE (@0), @1)
twice and when we save that result in a temporary, we can just use wi::neg_p
on that temporary.

2022-06-16  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/105984
	* match.pd (__builtin_mul_overflow_p (x, cst, (stype) 0) ->
	x > stype_max / cst || x < stype_min / cst): fold_convert @1
	to TREE_TYPE (@0) just once and test for negative divisor
	also on that folded constant instead of on @1.

	* gcc.c-torture/execute/pr105984.c: New test.
2022-06-16 14:36:04 +02:00
c++tools
config Daily bump. 2022-06-02 00:16:32 +00:00
contrib
fixincludes
gcc match.pd: Fix up __builtin_mul_overflow_p signed type optimization [PR105984] 2022-06-16 14:36:04 +02:00
gnattools
gotools
include Daily bump. 2022-06-14 00:16:39 +00:00
INSTALL
intl
libada
libatomic Daily bump. 2022-06-03 00:16:40 +00:00
libbacktrace
libcc1 Daily bump. 2022-06-02 00:16:32 +00:00
libcody Daily bump. 2022-06-04 00:16:27 +00:00
libcpp Daily bump. 2022-05-30 00:16:21 +00:00
libdecnumber
libffi
libgcc Daily bump. 2022-06-10 00:16:43 +00:00
libgfortran
libgo syscall: gofmt 2022-06-14 15:11:17 -07:00
libgomp Daily bump. 2022-06-16 00:16:44 +00:00
libiberty
libitm Daily bump. 2022-06-03 00:16:40 +00:00
libobjc
liboffloadmic
libphobos Daily bump. 2022-06-16 00:16:44 +00:00
libquadmath
libsanitizer
libssp
libstdc++-v3 Daily bump. 2022-06-16 00:16:44 +00:00
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.