aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2004-08-02 17:11:42 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2004-08-02 17:11:42 +0000
commit3159762032bc1d2d0a25d0d4047c4482cf81f8ff (patch)
tree9aef3176fe63484a7252787c6540785c7849d42b
parent25b656e7339c6c0466926faad63240e1e000ba35 (diff)
downloadgcc-3159762032bc1d2d0a25d0d4047c4482cf81f8ff.zip
gcc-3159762032bc1d2d0a25d0d4047c4482cf81f8ff.tar.gz
gcc-3159762032bc1d2d0a25d0d4047c4482cf81f8ff.tar.bz2
fold-const.c (fold): The transformation "X % -Y" -> "X % Y" is only valid for TRUNC_MOD_EXPR.
* fold-const.c (fold) <TRUNC_MOD_EXPR>: The transformation "X % -Y" -> "X % Y" is only valid for TRUNC_MOD_EXPR. From-SVN: r85443
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/fold-const.c10
2 files changed, 11 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 23750e3..db525b4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 23f7576..f4a6fb0 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -7624,8 +7624,9 @@ fold (tree expr)
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
@@ -7634,8 +7635,9 @@ fold (tree expr)
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),