diff options
author | Marek Polacek <polacek@redhat.com> | 2014-11-13 10:17:51 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2014-11-13 10:17:51 +0000 |
commit | 6a4f06787f9c0a9806a3f67a73dd12c33a8e8071 (patch) | |
tree | e233c5cc245878914cc351b054d0a383873e68eb | |
parent | 882de2147813cd2b848e1b6295dff6cb82d29852 (diff) | |
download | gcc-6a4f06787f9c0a9806a3f67a73dd12c33a8e8071.zip gcc-6a4f06787f9c0a9806a3f67a73dd12c33a8e8071.tar.gz gcc-6a4f06787f9c0a9806a3f67a73dd12c33a8e8071.tar.bz2 |
tree.h (TYPE_OVERFLOW_SANITIZED): Define.
* tree.h (TYPE_OVERFLOW_SANITIZED): Define.
* fold-const.c (fold_binary_loc): Use it.
* match.pd: Likewise.
From-SVN: r217470
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 4 | ||||
-rw-r--r-- | gcc/match.pd | 12 | ||||
-rw-r--r-- | gcc/tree.h | 6 |
4 files changed, 16 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 613208d..be3f64d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-11-13 Marek Polacek <polacek@redhat.com> + + * tree.h (TYPE_OVERFLOW_SANITIZED): Define. + * fold-const.c (fold_binary_loc): Use it. + * match.pd: Likewise. + 2014-11-14 Kirill Yukhin <kirill.yukhin@intel.com> * gcc/lra-lives.c (struct bb_data): Rename to ... diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 2f32d3c..a711be9 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -10516,9 +10516,7 @@ fold_binary_loc (location_t loc, /* A - B -> A + (-B) if B is easily negatable. */ if (negate_expr_p (arg1) - && (!INTEGRAL_TYPE_P (type) - || TYPE_OVERFLOW_WRAPS (type) - || (flag_sanitize & SANITIZE_SI_OVERFLOW) == 0) + && !TYPE_OVERFLOW_SANITIZED (type) && ((FLOAT_TYPE_P (type) /* Avoid this transformation if B is a positive REAL_CST. */ && (TREE_CODE (arg1) != REAL_CST diff --git a/gcc/match.pd b/gcc/match.pd index 25711b6..5a42320 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -285,26 +285,20 @@ along with GCC; see the file COPYING3. If not see /* Apply STRIP_NOPS on @0 and the negate. */ (if (tree_nop_conversion_p (type, TREE_TYPE (@0)) && tree_nop_conversion_p (type, TREE_TYPE (@1)) - && (!INTEGRAL_TYPE_P (type) - || TYPE_OVERFLOW_WRAPS (type) - || (flag_sanitize & SANITIZE_SI_OVERFLOW) == 0)) + && !TYPE_OVERFLOW_SANITIZED (type)) (minus (convert @0) (convert @1)))) /* A - (-B) -> A + B */ (simplify (minus (convert1? @0) (convert2? (negate @1))) (if (tree_nop_conversion_p (type, TREE_TYPE (@0)) && tree_nop_conversion_p (type, TREE_TYPE (@1)) - && (!INTEGRAL_TYPE_P (type) - || TYPE_OVERFLOW_WRAPS (type) - || (flag_sanitize & SANITIZE_SI_OVERFLOW) == 0)) + && !TYPE_OVERFLOW_SANITIZED (type)) (plus (convert @0) (convert @1)))) /* -(-A) -> A */ (simplify (negate (convert? (negate @1))) (if (tree_nop_conversion_p (type, TREE_TYPE (@1)) - && (!INTEGRAL_TYPE_P (type) - || TYPE_OVERFLOW_WRAPS (type) - || (flag_sanitize & SANITIZE_SI_OVERFLOW) == 0)) + && !TYPE_OVERFLOW_SANITIZED (type)) (convert @1))) /* We can't reassociate floating-point or fixed-point plus or minus @@ -789,6 +789,12 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int, #define TYPE_OVERFLOW_TRAPS(TYPE) \ (!TYPE_UNSIGNED (TYPE) && flag_trapv) +/* True if an overflow is to be preserved for sanitization. */ +#define TYPE_OVERFLOW_SANITIZED(TYPE) \ + (INTEGRAL_TYPE_P (TYPE) \ + && !TYPE_OVERFLOW_WRAPS (TYPE) \ + && (flag_sanitize & SANITIZE_SI_OVERFLOW)) + /* True if pointer types have undefined overflow. */ #define POINTER_TYPE_OVERFLOW_UNDEFINED (flag_strict_overflow) |