+2017-02-22 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/79666
+ * tree-vrp.c (extract_range_from_binary_expr_1): Make sure
+ to not symbolically negate if that may introduce undefined
+ overflow.
+
2017-02-22 Martin Liska <mliska@suse.cz>
PR lto/79587
+2017-02-22 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/79666
+ * gcc.dg/torture/pr79666.c: New testcase.
+
2017-02-22 Martin Liska <mliska@suse.cz>
PR lto/79587
min = build_symbolic_expr (expr_type, sym_min_op0,
neg_min_op0, min);
else if (sym_min_op1)
- min = build_symbolic_expr (expr_type, sym_min_op1,
- neg_min_op1 ^ minus_p, min);
+ {
+ /* We may not negate if that might introduce
+ undefined overflow. */
+ if (! minus_p
+ || neg_min_op1
+ || TYPE_OVERFLOW_WRAPS (expr_type))
+ min = build_symbolic_expr (expr_type, sym_min_op1,
+ neg_min_op1 ^ minus_p, min);
+ else
+ min = NULL_TREE;
+ }
/* Likewise for the upper bound. */
if (sym_max_op0 == sym_max_op1)
max = build_symbolic_expr (expr_type, sym_max_op0,
neg_max_op0, max);
else if (sym_max_op1)
- max = build_symbolic_expr (expr_type, sym_max_op1,
- neg_max_op1 ^ minus_p, max);
+ {
+ /* We may not negate if that might introduce
+ undefined overflow. */
+ if (! minus_p
+ || neg_max_op1
+ || TYPE_OVERFLOW_WRAPS (expr_type))
+ max = build_symbolic_expr (expr_type, sym_max_op1,
+ neg_max_op1 ^ minus_p, max);
+ else
+ max = NULL_TREE;
+ }
}
else
{