* expr.c (expand_expr <MULT_EXPR>): Remove inappropriate and
confusing comment; distributivity isn't handled in expand_expr.
* fold-const.c (extract_muldiv_1 <PLUS_EXPR>): Allow overflow
in distributivity, if wrap-around semantics are specified with
-fwrapv.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73166
138bc75d-0d04-0410-961f-
82ee72b054a4
+2003-10-31 Roger Sayle <roger@eyesopen.com>
+
+ PR middle-end/11968
+ * expr.c (expand_expr <MULT_EXPR>): Remove inappropriate and
+ confusing comment; distributivity isn't handled in expand_expr.
+ * fold-const.c (extract_muldiv_1 <PLUS_EXPR>): Allow overflow
+ in distributivity, if wrap-around semantics are specified with
+ -fwrapv.
+
2003-11-01 Alan Modra <amodra@bigpond.net.au>
PR 12315
op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode,
EXPAND_SUM);
- /* If we knew for certain that this is arithmetic for an array
- reference, and we knew the bounds of the array, then we could
- apply the distributive law across (PLUS X C) for constant C.
- Without such knowledge, we risk overflowing the computation
- when both X and C are large, but X+C isn't. */
- /* ??? Could perhaps special-case EXP being unsigned and C being
- positive. In that case we are certain that X+C is no smaller
- than X and so the transformed expression will overflow iff the
- original would have. */
-
if (GET_CODE (op0) != REG)
op0 = force_operand (op0, NULL_RTX);
if (GET_CODE (op0) != REG)
if (code == MULT_EXPR
|| integer_zerop (const_binop (TRUNC_MOD_EXPR, op1, c, 0)))
{
- op1 = const_binop (code, convert (ctype, op1), convert (ctype, c), 0);
- if (op1 == 0 || TREE_OVERFLOW (op1))
+ op1 = const_binop (code, convert (ctype, op1),
+ convert (ctype, c), 0);
+ /* We allow the constant to overflow with wrapping semantics. */
+ if (op1 == 0
+ || (TREE_OVERFLOW (op1) && ! flag_wrapv))
break;
}
else