aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2018-12-04 11:26:14 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2018-12-04 11:26:14 +0000
commitf0e98f1bb47ab5827d89bd6a16f4263e20549da3 (patch)
treec94680254a872e943a7636c01b5e6dc3a5ec0544 /gcc
parent580b8d9b540761e4df47d22fbfc9372396db8748 (diff)
downloadgcc-f0e98f1bb47ab5827d89bd6a16f4263e20549da3.zip
gcc-f0e98f1bb47ab5827d89bd6a16f4263e20549da3.tar.gz
gcc-f0e98f1bb47ab5827d89bd6a16f4263e20549da3.tar.bz2
re PR tree-optimization/88301 (Optimization regression with undefined unsigned overflow)
2018-12-04 Richard Biener <rguenther@suse.de> PR tree-optimization/88301 * tree-vrp.c (register_edge_assert_for_2): Fix sign-conversion issues in last commit. From-SVN: r266773
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/tree-vrp.c15
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 335caf6..4bb7187 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2018-12-04 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/88301
+ * tree-vrp.c (register_edge_assert_for_2): Fix sign-conversion
+ issues in last commit.
+
+2018-12-04 Richard Biener <rguenther@suse.de>
+
PR tree-optimization/88315
* tree-vect-loop.c (get_initial_defs_for_reduction): Simplify
and fix initialization vector for SAD and DOT_PROD SLP reductions.
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index b00eca8..6fd1fd2 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -2973,6 +2973,21 @@ register_edge_assert_for_2 (tree name, edge e,
wide_int rmin, rmax;
tree rhs1 = gimple_assign_rhs1 (def_stmt);
if (INTEGRAL_TYPE_P (TREE_TYPE (rhs1))
+ /* Make sure the relation preserves the upper/lower boundary of
+ the range conservatively. */
+ && (comp_code == NE_EXPR
+ || comp_code == EQ_EXPR
+ || (TYPE_SIGN (TREE_TYPE (name))
+ == TYPE_SIGN (TREE_TYPE (rhs1)))
+ || ((comp_code == LE_EXPR
+ || comp_code == LT_EXPR)
+ && !TYPE_UNSIGNED (TREE_TYPE (rhs1)))
+ || ((comp_code == GE_EXPR
+ || comp_code == GT_EXPR)
+ && TYPE_UNSIGNED (TREE_TYPE (rhs1))))
+ /* And the conversion does not alter the value we compare
+ against and all values in rhs1 can be represented in
+ the converted to type. */
&& int_fits_type_p (val, TREE_TYPE (rhs1))
&& ((TYPE_PRECISION (TREE_TYPE (name))
> TYPE_PRECISION (TREE_TYPE (rhs1)))