+2004-08-02 Roger Sayle <roger@eyesopen.com>
+
+ * fold-const.c (fold) <TRUNC_MOD_EXPR>: The transformation "X % -Y"
+ -> "X % Y" is only valid for TRUNC_MOD_EXPR.
+
2004-08-02 Gabriel Dos Reis <gdr@integrable-solutions.net>
* vec.h (DEF_VEC_P): Add proper cast to uses of vec_o_reserve and
fold_convert (type, arg0), mask));
}
- /* X % -C is the same as X % C (for all rounding moduli). */
- if (!TYPE_UNSIGNED (type)
+ /* X % -C is the same as X % C. */
+ if (code == TRUNC_MOD_EXPR
+ && !TYPE_UNSIGNED (type)
&& TREE_CODE (arg1) == INTEGER_CST
&& TREE_INT_CST_HIGH (arg1) < 0
&& !flag_trapv
return fold (build2 (code, type, fold_convert (type, arg0),
fold_convert (type, negate_expr (arg1))));
- /* X % -Y is the same as X % Y (for all rounding moduli). */
- if (!TYPE_UNSIGNED (type)
+ /* X % -Y is the same as X % Y. */
+ if (code == TRUNC_MOD_EXPR
+ && !TYPE_UNSIGNED (type)
&& TREE_CODE (arg1) == NEGATE_EXPR
&& !flag_trapv)
return fold (build2 (code, type, fold_convert (type, arg0),