diff options
author | Ian Lance Taylor <iant@google.com> | 2007-01-28 05:15:06 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2007-01-28 05:15:06 +0000 |
commit | eeef0e452e98fe6424ce65fb25fba15c59151848 (patch) | |
tree | 0e2fc9b10a02a481f17a188d9e01389ef7691fb4 /gcc/doc | |
parent | b73a6056563470e5b99e79a0dc769c351e906e6e (diff) | |
download | gcc-eeef0e452e98fe6424ce65fb25fba15c59151848.tar.gz |
common.opt: Add fstrict-overflow.
./: * 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.
From-SVN: r121254
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/invoke.texi | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index fee5871dc89..eb55c9b321a 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -341,7 +341,7 @@ Objective-C and Objective-C++ Dialects}. -fsched2-use-traces -fsee -freschedule-modulo-scheduled-loops @gol -fsection-anchors -fsignaling-nans -fsingle-precision-constant @gol -fstack-protector -fstack-protector-all @gol --fstrict-aliasing -ftracer -fthread-jumps @gol +-fstrict-aliasing -fstrict-overflow -ftracer -fthread-jumps @gol -funroll-all-loops -funroll-loops -fpeel-loops @gol -fsplit-ivs-in-unroller -funswitch-loops @gol -fvariable-expansion-in-unroller @gol @@ -4635,7 +4635,7 @@ also turns on the following optimization flags: -fschedule-insns -fschedule-insns2 @gol -fsched-interblock -fsched-spec @gol -fregmove @gol --fstrict-aliasing @gol +-fstrict-aliasing -fstrict-overflow @gol -fdelete-null-pointer-checks @gol -freorder-blocks -freorder-functions @gol -falign-functions -falign-jumps @gol @@ -5465,6 +5465,32 @@ int f() @{ Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. +@item -fstrict-overflow +@opindex fstrict-overflow +Allow the compiler to assume strict signed overflow rules, depending +on the language being compiled. For C (and C++) this means that +overflow when doing arithmetic with signed numbers is undefined, which +means that the compiler may assume that it will not happen. This +permits various optimizations. For example, the compiler will assume +that an expression like @code{i + 10 > i} will always be true for +signed @code{i}. This assumption is only valid if signed overflow is +undefined, as the expression is false if @code{i + 10} overflows when +using twos complement arithmetic. When this option is in effect any +attempt to determine whether an operation on signed numbers will +overflow must be written carefully to not actually involve overflow. + +See also the @option{-fwrapv} option. Using @option{-fwrapv} means +that signed overflow is fully defined: it wraps. When +@option{-fwrapv} is used, there is no difference between +@option{-fstrict-overflow} and @option{-fno-strict-overflow}. With +@option{-fwrapv} certain types of overflow are permitted. For +example, if the compiler gets an overflow when doing arithmetic on +constants, the overflowed value can still be used with +@option{-fwrapv}, but not otherwise. + +The @option{-fstrict-overflow} option is enabled at levels +@option{-O2}, @option{-O3}, @option{-Os}. + @item -falign-functions @itemx -falign-functions=@var{n} @opindex falign-functions |