aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorMark Mitchell <mmitchel@gcc.gnu.org>2003-03-23 22:57:26 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2003-03-23 22:57:26 +0000
commit068d2c9db6aa8553b34925ea0c0957e8ce671e30 (patch)
treee1c8674477700f6ed2edd93d67199d024ef407d1 /gcc/fold-const.c
parentc967e28c2fc6e87601f1ef89f44baff7f53083ea (diff)
downloadgcc-068d2c9db6aa8553b34925ea0c0957e8ce671e30.zip
gcc-068d2c9db6aa8553b34925ea0c0957e8ce671e30.tar.gz
gcc-068d2c9db6aa8553b34925ea0c0957e8ce671e30.tar.bz2
re PR c/8224 (Incorrect joining of signed and unsigned division)
PR c/8224 * fold-const.c (extract_muldiv_1): Don't pass through type conversions when signedness changes for division or modulus. PR c/8224 * gcc.dg/20030323-1.c: New test. From-SVN: r64760
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 7b051fa..0f9f3d4 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -4170,7 +4170,12 @@ extract_muldiv_1 (t, c, code, wide_type)
/* ... or its type is larger than ctype,
then we cannot pass through this truncation. */
|| (GET_MODE_SIZE (TYPE_MODE (ctype))
- < GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op0))))))
+ < GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op0))))
+ /* ... or signedness changes for division or modulus,
+ then we cannot pass through this conversion. */
+ || (code != MULT_EXPR
+ && (TREE_UNSIGNED (ctype)
+ != TREE_UNSIGNED (TREE_TYPE (op0))))))
break;
/* Pass the constant down and see if we can make a simplification. If