aboutsummaryrefslogtreecommitdiff
path: root/gcc/expmed.c
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2013-08-24 00:16:08 +0200
committerMarc Glisse <glisse@gcc.gnu.org>2013-08-23 22:16:08 +0000
commit0cadbfaa89805ce4d1b93bed04c10d7c7bf1f6e2 (patch)
treefd1a5007e3c6c876ebf4f1982aa74584d82afc0d /gcc/expmed.c
parent4500f676e138a5ea3337ebd47745d8b49ba775b5 (diff)
downloadgcc-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/expmed.c')
-rw-r--r--gcc/expmed.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c
index 79f3424..d18f09f 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -3697,11 +3697,11 @@ expand_smod_pow2 (enum machine_mode mode, rtx op0, HOST_WIDE_INT d)
masklow = ((HOST_WIDE_INT) 1 << logd) - 1;
if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
{
- masklow |= (HOST_WIDE_INT) -1 << (GET_MODE_BITSIZE (mode) - 1);
+ masklow |= HOST_WIDE_INT_M1U << (GET_MODE_BITSIZE (mode) - 1);
maskhigh = -1;
}
else
- maskhigh = (HOST_WIDE_INT) -1
+ maskhigh = HOST_WIDE_INT_M1U
<< (GET_MODE_BITSIZE (mode) - HOST_BITS_PER_WIDE_INT - 1);
temp = expand_binop (mode, and_optab, op0,
@@ -3715,7 +3715,7 @@ expand_smod_pow2 (enum machine_mode mode, rtx op0, HOST_WIDE_INT d)
temp = expand_binop (mode, sub_optab, result, const1_rtx, result,
0, OPTAB_LIB_WIDEN);
- masklow = (HOST_WIDE_INT) -1 << logd;
+ masklow = HOST_WIDE_INT_M1U << logd;
maskhigh = -1;
temp = expand_binop (mode, ior_optab, temp,
immed_double_const (masklow, maskhigh, mode),