Jakub Jelinek 9e603837f7 wide-int: Fix wi::to_mpz [PR98474]
The following testcase is miscompiled, because niter analysis miscomputes
the number of iterations to 0.
The problem is that niter analysis uses mpz_t (wonder why, wouldn't
widest_int do the same job?) and when wi::to_mpz is called e.g. on the
TYPE_MAX_VALUE of __uint128_t, it initializes the mpz_t result with wrong
value.
wi::to_mpz has code to handle negative wide_ints in signed types by
inverting all bits, importing to mpz and complementing it, which is fine,
but doesn't handle correctly the case when the wide_int's len (times
HOST_BITS_PER_WIDE_INT) is smaller than precision when wi::neg_p.
E.g. the 0xffffffffffffffffffffffffffffffff TYPE_MAX_VALUE is represented
in wide_int as 0xffffffffffffffff len 1, and wi::to_mpz would create
0xffffffffffffffff mpz_t value from that.
This patch handles it by adding the needed -1 host wide int words (and has
also code to deal with precision that aren't multiple of
HOST_BITS_PER_WIDE_INT).

2020-12-31  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/98474
	* wide-int.cc (wi::to_mpz): If wide_int has MSB set, but type
	is unsigned and excess negative, append set bits after len until
	precision.

	* gcc.c-torture/execute/pr98474.c: New test.
2020-12-31 11:06:56 +01:00
2020-12-24 00:16:26 +00:00
2020-11-26 00:16:41 +00:00
2020-12-22 00:16:23 +00:00
2020-12-15 00:16:35 +00:00
2020-12-31 11:06:56 +01:00
2020-12-31 00:16:29 +00:00
2020-12-10 00:16:47 +00:00
2020-12-06 00:16:44 +00:00
2020-12-06 00:16:44 +00:00
2020-12-19 00:16:31 +00:00
2020-12-24 00:16:26 +00:00
2020-12-15 00:16:35 +00:00
2020-12-06 00:16:44 +00:00
2020-12-21 00:16:20 +00:00
2020-12-06 00:16:44 +00:00
2020-12-29 00:16:34 +00:00
2020-12-06 00:16:44 +00:00
2020-12-23 00:16:35 +00:00
2020-12-06 00:16:44 +00:00
2020-12-06 00:16:44 +00:00
2020-11-30 00:16:27 +00:00
2020-12-06 00:16:44 +00:00
2020-12-06 00:16:44 +00:00
2020-12-06 00:16:44 +00:00
2020-12-06 00:16:44 +00:00
2020-12-28 00:16:28 +00:00
2020-12-06 00:16:44 +00:00
2020-11-30 00:16:27 +00:00
2020-12-17 00:16:37 +00:00
2020-12-06 00:16:44 +00:00
2020-12-02 11:04:01 -07:00
2020-12-18 00:16:30 +00:00
2020-12-15 07:42:59 -08:00
2020-12-15 07:42:59 -08:00
2020-12-15 07:42:59 -08:00
2020-12-15 07:42:59 -08:00
2020-12-15 07:42:59 -08:00

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.
Description
No description provided
Readme 4.2 GiB
Languages
C++ 30.8%
C 30.2%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.3%