diff options
author | Richard Biener <rguenther@suse.de> | 2022-01-26 09:35:57 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2022-02-04 14:38:47 +0100 |
commit | 0898049ad9bf6c46e510b18aaafca4946802749f (patch) | |
tree | 14ebaafca33c719cbde7610151467bfac7e7f6ad /gcc/fold-const.h | |
parent | 9d3236ff3791ea74e1bc1c293d82fee11b1a5e24 (diff) | |
download | gcc-0898049ad9bf6c46e510b18aaafca4946802749f.zip gcc-0898049ad9bf6c46e510b18aaafca4946802749f.tar.gz gcc-0898049ad9bf6c46e510b18aaafca4946802749f.tar.bz2 |
tree-optimization/100499 - niter analysis and multiple_of_p
niter analysis uses multiple_of_p which currently assumes
operations like MULT_EXPR do not wrap. We've got to rely on this
for optimizing size expressions like those in DECL_SIZE and those
generally use unsigned arithmetic with no indication that they
are not expected to wrap. To preserve that the following adds
a parameter to multiple_of_p, defaulted to true, indicating that
the TOP expression is not expected to wrap for outer computations
in TYPE. This mostly follows a patch proposed by Bin last year
with the conversion behavior added.
Applying to all users the new effect is that upon type conversions
in the TOP expression the behavior will switch to honor
TYPE_OVERFLOW_UNDEFINED for the converted sub-expressions.
The patch also changes the occurance in niter analysis that we
know is problematic and we have testcases for to pass false
to multiple_of_p. The patch also contains a change to the
PR72817 fix from Bin to avoid regressing gcc.dg/tree-ssa/loop-42.c.
The intent for stage1 is to introduce a size_multiple_of_p and
internalize the added parameter so all multiple_of_p users will
honor TYPE_OVERFLOW_UNDEFINED and users dealing with size expressions
need to be switched to size_multiple_of_p.
2022-01-26 Richard Biener <rguenther@suse.de>
PR tree-optimization/100499
* fold-const.h (multiple_of_p): Add nowrap parameter, defaulted
to true.
* fold-const.cc (multiple_of_p): Likewise. Honor it for
MULT_EXPR, PLUS_EXPR and MINUS_EXPR and pass it along,
switching to false for conversions.
* tree-ssa-loop-niter.cc (number_of_iterations_ne): Do not
claim the outermost expression does not wrap when calling
multiple_of_p. Refactor the check done to check the
original IV, avoiding a bias that might wrap.
* gcc.dg/torture/pr100499-1.c: New testcase.
* gcc.dg/torture/pr100499-2.c: Likewise.
* gcc.dg/torture/pr100499-3.c: Likewise.
Co-authored-by: Bin Cheng <bin.cheng@linux.alibaba.com>
Diffstat (limited to 'gcc/fold-const.h')
-rw-r--r-- | gcc/fold-const.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/fold-const.h b/gcc/fold-const.h index 394a67e..d36bfc8 100644 --- a/gcc/fold-const.h +++ b/gcc/fold-const.h @@ -96,7 +96,7 @@ extern void fold_overflow_warning (const char*, enum warn_strict_overflow_code); extern enum tree_code fold_div_compare (enum tree_code, tree, tree, tree *, tree *, bool *); extern bool operand_equal_p (const_tree, const_tree, unsigned int flags = 0); -extern int multiple_of_p (tree, const_tree, const_tree); +extern int multiple_of_p (tree, const_tree, const_tree, bool = true); #define omit_one_operand(T1,T2,T3)\ omit_one_operand_loc (UNKNOWN_LOCATION, T1, T2, T3) extern tree omit_one_operand_loc (location_t, tree, tree, tree); |