diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-28 05:15:06 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-28 05:15:06 +0000 |
commit | 981eb79841b74e439cb66e6f6bf2f0abdf7524b5 (patch) | |
tree | 0e2fc9b10a02a481f17a188d9e01389ef7691fb4 /gcc/tree-vrp.c | |
parent | 426a138f1f231a55f4670be9c4bca30dbb0e3b61 (diff) | |
download | gcc-981eb79841b74e439cb66e6f6bf2f0abdf7524b5.tar.gz |
./:
* common.opt: Add fstrict-overflow.
* opts.c (decode_options): Set flag_strict_overflow if -O2.
* flags.h (TYPE_OVERFLOW_WRAPS): Define.
(TYPE_OVERFLOW_UNDEFINED): Define.
(TYPE_OVERFLOW_TRAPS): Define. This replaces TYPE_TRAP_SIGNED.
Replace all uses.
* tree.h (TYPE_TRAP_SIGNED): Don't define.
* fold-const.c (negate_expr_p): Use TYPE_OVERFLOW_UNDEFINED.
(fold_negate_expr): Likewise.
(make_range): Likewise.
(extract_muldiv_1): Likewise.
(maybe_canonicalize_comparison): Likewise.
(fold_comparison): Likewise.
(fold_binary): Likewise.
(tree_expr_nonnegative_p): Likewise.
(tree_expr_nonzero_p): Likewise.
* tree-vrp.c (compare_values): Likewise.
(extract_range_from_binary_expr): Likewise.
(extract_range_from_unary_expr): Likewise.
* tree-ssa-loop-niter.c (infer_loop_bounds_from_signedness):
Likewise.
(nowrap_type_p): Likewise.
* tree-scalar-evolution.c (simple_iv): Likewise.
* fold-const.c (negate_expr_p): Use TYPE_OVERFLOW_WRAPS.
(build_range_check): Likewise.
(extract_muldiv_1): Likewise.
(fold_comparison): Likewise.
* tree-vrp.c (vrp_int_const_binop): Likewise.
(extract_range_from_unary_expr): Likewise.
* convert.c (convert_to_integer): Likewise.
* fold-const.c (fold_negate_expr): Use TYPE_OVERFLOW_TRAPS.
(fold_comparison): Likewise.
(fold_binary): Likewise.
* optabs.c (optab_for_tree_code): Likewise.
* tree-vectorizer.c (vect_is_simple_reduction): Likewise.
* simplify-rtx.c (simplify_const_relational_operation): Check
flag_strict_overflow and flag_trapv.
(simplify_const_relational_operation): Likewise.
* doc/invoke.texi (Option Summary): Mention -fstrict-overflow.
(Optimize Options): Add -fstrict-overflow to -O2 list. Document
-fstrict-overflow.
testsuite/:
* gcc.dg/strict-overflow-1.c: New test.
* gcc.dg/no-strict-overflow-1.c: New test.
* gcc.dg/strict-overflow-2.c: New test.
* gcc.dg/no-strict-overflow-2.c: New test.
* gcc.dg/strict-overflow-3.c: New test.
* gcc.dg/no-strict-overflow-3.c: New test.
* gcc.dg/strict-overflow-4.c: New test.
* gcc.dg/no-strict-overflow-4.c: New test.
* gcc.dg/fold-mod-1.c: Add -fstrict-overflow option.
* gcc.dg/pr15784-1.c: Likewise.
* gcc.dg/pr20922-1.c: Likewise.
* gcc.dg/pr20922-3.c: Likewise.
* gcc.dg/pr20922-4.c: Likewise.
* gcc.dg/pr20922-6.c: Likewise.
* gcc.dg/compare-4.c: Likewise.
* gcc.dg/torture/pr26898-1.c: Likewise.
* gcc.dg/tree-ssa/divide-1.c: Likewise.
* gcc.dg/tree-ssa/divide-2.c: Likewise.
* gcc.dg/tree-ssa/divide-3.c: Likewise.
* gcc.dg/tree-ssa/divide-4.c: Likewise.
* gcc.dg/tree-ssa/pr14490-1.c: Likewise.
* gcc.dg/tree-ssa/pr14490-3.c: Likewise.
* gcc.dg/tree-ssa/pr21082.c: Likewise.
* gcc.dg/tree-ssa/pr26899.c: Likewise.
* g++.dg/tree-ssa/pr21082.C: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121254 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 6fb2a7271ba..86f3d1c3710 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1,5 +1,5 @@ /* Support routines for Value Range Propagation (VRP). - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. Contributed by Diego Novillo <dnovillo@redhat.com>. This file is part of GCC. @@ -570,8 +570,7 @@ compare_values (tree val1, tree val2) return 0; /* If overflow is defined we cannot simplify more. */ - if (TYPE_UNSIGNED (TREE_TYPE (val1)) - || flag_wrapv) + if (!TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (val1))) return -2; if (code1 == SSA_NAME) @@ -1215,8 +1214,7 @@ vrp_int_const_binop (enum tree_code code, tree val1, tree val2) /* If we are not using wrapping arithmetic, operate symbolically on -INF and +INF. */ - if (TYPE_UNSIGNED (TREE_TYPE (val1)) - || flag_wrapv) + if (TYPE_OVERFLOW_WRAPS (TREE_TYPE (val1))) { int checkz = compare_values (res, val1); bool overflow = false; @@ -1503,7 +1501,7 @@ extract_range_from_binary_expr (value_range_t *vr, tree expr) point. */ if (code == MULT_EXPR && vr0.type == VR_ANTI_RANGE - && (flag_wrapv || TYPE_UNSIGNED (TREE_TYPE (op0)))) + && !TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (op0))) { set_value_range_to_varying (vr); return; @@ -1799,11 +1797,12 @@ extract_range_from_unary_expr (value_range_t *vr, tree expr) ? TYPE_MIN_VALUE (TREE_TYPE (expr)) : fold_unary_to_constant (code, TREE_TYPE (expr), vr0.max); - max = vr0.min == TYPE_MIN_VALUE (TREE_TYPE (expr)) - ? (vr0.type == VR_ANTI_RANGE || flag_wrapv - ? TYPE_MIN_VALUE (TREE_TYPE (expr)) - : TYPE_MAX_VALUE (TREE_TYPE (expr))) - : fold_unary_to_constant (code, TREE_TYPE (expr), vr0.min); + max = (vr0.min == TYPE_MIN_VALUE (TREE_TYPE (expr)) + ? ((vr0.type == VR_ANTI_RANGE + || TYPE_OVERFLOW_WRAPS (TREE_TYPE (expr))) + ? TYPE_MIN_VALUE (TREE_TYPE (expr)) + : TYPE_MAX_VALUE (TREE_TYPE (expr))) + : fold_unary_to_constant (code, TREE_TYPE (expr), vr0.min)); } else if (code == NEGATE_EXPR @@ -1828,7 +1827,7 @@ extract_range_from_unary_expr (value_range_t *vr, tree expr) { /* -TYPE_MIN_VALUE = TYPE_MIN_VALUE with flag_wrapv so we can't get a useful range. */ - if (flag_wrapv + if (!TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (expr)) && ((vr0.type == VR_RANGE && vr0.min == TYPE_MIN_VALUE (TREE_TYPE (expr))) || (vr0.type == VR_ANTI_RANGE @@ -1865,7 +1864,8 @@ extract_range_from_unary_expr (value_range_t *vr, tree expr) or ~[-INF + 1, min (abs(MIN), abs(MAX))] when flag_wrapv is set and the original anti-range doesn't include TYPE_MIN_VALUE, remember -TYPE_MIN_VALUE = TYPE_MIN_VALUE. */ - min = (flag_wrapv && vr0.min != type_min_value + min = ((TYPE_OVERFLOW_WRAPS (TREE_TYPE (expr)) + && vr0.min != type_min_value) ? int_const_binop (PLUS_EXPR, type_min_value, integer_one_node, 0) |