diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2013-08-24 00:16:08 +0200 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2013-08-23 22:16:08 +0000 |
commit | 0cadbfaa89805ce4d1b93bed04c10d7c7bf1f6e2 (patch) | |
tree | fd1a5007e3c6c876ebf4f1982aa74584d82afc0d /gcc/simplify-rtx.c | |
parent | 4500f676e138a5ea3337ebd47745d8b49ba775b5 (diff) | |
download | gcc-0cadbfaa89805ce4d1b93bed04c10d7c7bf1f6e2.zip gcc-0cadbfaa89805ce4d1b93bed04c10d7c7bf1f6e2.tar.gz gcc-0cadbfaa89805ce4d1b93bed04c10d7c7bf1f6e2.tar.bz2 |
re PR other/57324 (Undefined behavior issues found with clang's -fsanitize=undefined)
2013-08-24 Marc Glisse <marc.glisse@inria.fr>
PR other/57324
* hwint.h (HOST_WIDE_INT_UC, HOST_WIDE_INT_1U, HOST_WIDE_INT_M1,
HOST_WIDE_INT_M1U): New macros.
* fold-const.c (sign_bit_p, build_range_check, fold_unary_loc,
fold_binary_loc, fold_ternary_loc): Use the new macros. Use an
unsigned -1 for lshift.
* cse.c (cse_insn): Likewise.
* double-int.c (rshift_double, lshift_double): Likewise.
* builtins.c (fold_builtin_bitop): Likewise.
* combine.c (force_to_mode): Likewise.
* tree.c (integer_pow2p, tree_log2, tree_floor_log2): Likewise.
* simplify-rtx.c (simplify_const_unary_operation,
simplify_const_binary_operation): Likewise.
* tree-stdarg.c (va_list_counter_bump, va_list_ptr_read,
check_va_list_escapes): Likewise.
* rtlanal.c (nonzero_bits1): Likewise.
* expmed.c (expand_smod_pow2): Likewise.
* tree-ssa-structalias.c (UNKNOWN_OFFSET): Use HOST_WIDE_INT_MIN.
From-SVN: r201953
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r-- | gcc/simplify-rtx.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 17a3d12..65a5906 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2018,14 +2018,13 @@ simplify_const_unary_operation (enum rtx_code code, enum machine_mode mode, /* Test against the signed lower bound. */ if (width > HOST_BITS_PER_WIDE_INT) { - th = (unsigned HOST_WIDE_INT) (-1) - << (width - HOST_BITS_PER_WIDE_INT - 1); + th = HOST_WIDE_INT_M1U << (width - HOST_BITS_PER_WIDE_INT - 1); tl = 0; } else { th = -1; - tl = (unsigned HOST_WIDE_INT) (-1) << (width - 1); + tl = HOST_WIDE_INT_M1U << (width - 1); } real_from_integer (&t, VOIDmode, tl, th, 0); if (REAL_VALUES_LESS (x, t)) @@ -4191,7 +4190,7 @@ simplify_const_binary_operation (enum rtx_code code, enum machine_mode mode, /* Sign-extend the result for arithmetic right shifts. */ if (code == ASHIFTRT && arg0s < 0 && arg1 > 0) - val |= ((unsigned HOST_WIDE_INT) (-1)) << (width - arg1); + val |= HOST_WIDE_INT_M1U << (width - arg1); break; case ROTATERT: |