Richard Sandiford 4cf70c20cb data-ref: Rework integer handling in split_constant_offset [PR98069]
PR98069 is about a case in which split_constant_offset miscategorises
an expression of the form:

  int foo;
  …
  POINTER_PLUS_EXPR<base, (sizetype)(INT_MIN - foo) * size>

as:

  base: base
  offset: (sizetype) (-foo) * size
  init: INT_MIN * size

“-foo” overflows when “foo” is INT_MIN, whereas the original expression
didn't overflow in that case.

As discussed in the PR trail, we could simply ignore the fact that
int overflow is undefined and treat it as a wrapping type, but that
is likely to pessimise quite a few cases.

This patch instead reworks split_constant_offset so that:

- it treats integer operations as having an implicit cast to sizetype
- for integer operations, the returned VAR has type sizetype

In other words, the problem becomes to express:

  (sizetype) (OP0 CODE OP1)

as:

  VAR:sizetype + (sizetype) OFF:ssizetype

The top-level integer split_constant_offset will (usually) be a sizetype
POINTER_PLUS operand, so the extra cast to sizetype disappears.  But adding
the cast allows the conversion handling to defer a lot of the difficult
cases to the recursive split_constant_offset call, which can detect
overflow on individual operations.

The net effect is to analyse the access above as:

  base: base
  offset: -(sizetype) foo * size
  init: INT_MIN * size

See the comments in the patch for more details.

gcc/
	PR tree-optimization/98069
	* tree-data-ref.c (compute_distributive_range): New function.
	(nop_conversion_for_offset_p): Likewise.
	(split_constant_offset): In the internal overload, treat integer
	expressions as having an implicit cast to sizetype and express
	them accordingly.  Pass back the range of the original (uncast)
	expression in a new range parameter.
	(split_constant_offset_1): Likewise.  Rework the handling of
	conversions to account for the implicit sizetype casts.
2020-12-10 12:10:00 +00:00
2020-11-26 00:16:41 +00:00
2020-12-09 00:16:50 +00:00
2020-11-19 00:16:30 +00:00
2020-10-30 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-06 00:16:44 +00:00
2020-12-02 00:16:41 +00:00
2020-07-31 00:16:26 +00:00
2020-12-06 00:16:44 +00:00
2020-12-09 00:16:50 +00:00
2020-12-06 00:16:44 +00:00
2020-12-08 14:01:04 -08:00
2020-12-10 00:16:47 +00:00
2020-12-06 00:16:44 +00:00
2020-11-26 00:16:41 +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-10 00:16:47 +00:00
2020-12-06 00:16:44 +00:00
2020-11-30 00:16:27 +00:00
2020-05-30 00:16:27 +00:00
2020-12-06 00:16:44 +00:00
2020-01-15 14:29:53 +01:00
2020-12-02 11:04:01 -07:00
2020-12-06 00:16:44 +00: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 2.1 GiB
Languages
C++ 31.9%
C 31.3%
Ada 12%
D 6.5%
Go 6.4%
Other 11.5%