From: Nick Clifton Date: Wed, 24 May 2000 18:24:06 +0000 (+0000) Subject: (extract_muldiv): When constructing a multiplier/divisor... X-Git-Tag: prereleases/libstdc++-2.92~6221 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d08230fe7def51b5ff3abfd4bde7da222989aa6c;p=thirdparty%2Fgcc.git (extract_muldiv): When constructing a multiplier/divisor... (extract_muldiv): When constructing a multiplier/divisor, do not expect const_binop to correctly determine if overflow has occured, so check explicitly. From-SVN: r34135 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b874d9ff9207..d3f281efbca7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2000-05-24 Nick Clifton + + * fold-const.c (extract_muldiv): When constructing a + multiplier/divisor, do not expect const_binop to correctly + determine if overflow has occured, so check explicitly. + 2000-05-24 Alexandre Oliva * c-decl.c (build_enumerator): Don't modify the value's type, diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 12a8d1a7a406..eec3bc48b76a 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -4451,6 +4451,10 @@ extract_muldiv (t, c, code, wide_type) or floor division, by a power of two, so we can treat it that way unless the multiplier or divisor overflows. */ if (TREE_CODE (op1) == INTEGER_CST + /* const_binop may not detect overflow correctly, + so check for it explicitly here. */ + && TYPE_PRECISION (TREE_TYPE (size_one_node)) > TREE_INT_CST_LOW (op1) + && TREE_INT_CST_HIGH (op1) == 0 && 0 != (t1 = convert (ctype, const_binop (LSHIFT_EXPR, size_one_node, op1, 0)))