diff options
author | Richard Guenther <rguenther@suse.de> | 2009-12-02 22:49:43 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2009-12-02 22:49:43 +0000 |
commit | 793e86a71bb5d4cca448a04a1d519898436bef66 (patch) | |
tree | 85e3f36ee7d7554d956c324f46cf85fc7b5e00f3 /gcc | |
parent | fc81a3692de25d1c1279844095513b033f9cfef8 (diff) | |
download | gcc-793e86a71bb5d4cca448a04a1d519898436bef66.zip gcc-793e86a71bb5d4cca448a04a1d519898436bef66.tar.gz gcc-793e86a71bb5d4cca448a04a1d519898436bef66.tar.bz2 |
fold-const.c (div_if_zero_remainder): Honor that sizetypes are sign-extending.
2009-12-02 Richard Guenther <rguenther@suse.de>
* fold-const.c (div_if_zero_remainder): Honor that sizetypes
are sign-extending. Simplify.
From-SVN: r154926
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fold-const.c | 24 |
2 files changed, 15 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 493f1f5..53ea0d2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2009-12-02 Richard Guenther <rguenther@suse.de> + + * fold-const.c (div_if_zero_remainder): Honor that sizetypes + are sign-extending. Simplify. + 2009-12-02 Richard Henderson <rth@redhat.com> PR tree-opt/42215 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 37475a0..cbdaf86 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -881,22 +881,18 @@ div_if_zero_remainder (enum tree_code code, const_tree arg1, const_tree arg2) HOST_WIDE_INT int1h, int2h; unsigned HOST_WIDE_INT quol, reml; HOST_WIDE_INT quoh, remh; - tree type = TREE_TYPE (arg1); - int uns = TYPE_UNSIGNED (type); + int uns; + + /* The sign of the division is according to operand two, that + does the correct thing for POINTER_PLUS_EXPR where we want + a signed division. */ + uns = TYPE_UNSIGNED (TREE_TYPE (arg2)); + if (TREE_CODE (TREE_TYPE (arg2)) == INTEGER_TYPE + && TYPE_IS_SIZETYPE (TREE_TYPE (arg2))) + uns = false; int1l = TREE_INT_CST_LOW (arg1); int1h = TREE_INT_CST_HIGH (arg1); - /* &obj[0] + -128 really should be compiled as &obj[-8] rather than - &obj[some_exotic_number]. */ - if (POINTER_TYPE_P (type)) - { - uns = false; - type = signed_type_for (type); - fit_double_type (int1l, int1h, &int1l, &int1h, - type); - } - else - fit_double_type (int1l, int1h, &int1l, &int1h, type); int2l = TREE_INT_CST_LOW (arg2); int2h = TREE_INT_CST_HIGH (arg2); @@ -905,7 +901,7 @@ div_if_zero_remainder (enum tree_code code, const_tree arg1, const_tree arg2) if (remh != 0 || reml != 0) return NULL_TREE; - return build_int_cst_wide (type, quol, quoh); + return build_int_cst_wide (TREE_TYPE (arg1), quol, quoh); } /* This is nonzero if we should defer warnings about undefined |