diff options
author | Richard Guenther <rguenther@suse.de> | 2008-02-12 21:26:49 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2008-02-12 21:26:49 +0000 |
commit | 8f768a5a18a47ce412c6455a6e802d4b703fcf26 (patch) | |
tree | 093d59274ea04e5e86cb95c9e81e640a0bbf85b8 /gcc/fold-const.c | |
parent | d2a18787b75b66176fac5a33be4c630054f26127 (diff) | |
download | gcc-8f768a5a18a47ce412c6455a6e802d4b703fcf26.zip gcc-8f768a5a18a47ce412c6455a6e802d4b703fcf26.tar.gz gcc-8f768a5a18a47ce412c6455a6e802d4b703fcf26.tar.bz2 |
re PR middle-end/35163 (folding comparison loses cast)
2008-02-12 Richard Guenther <rguenther@suse.de>
PR middle-end/35163
* fold-const.c (fold_widened_comparison): Use get_unwidened in
value-preserving mode. Disallow final truncation.
* gcc.c-torture/execute/pr35163.c: New testcase.
From-SVN: r132269
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index ea0b43e..a33b2b0 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7045,12 +7045,14 @@ fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1) if (TYPE_PRECISION (TREE_TYPE (arg0)) <= TYPE_PRECISION (shorter_type)) return NULL_TREE; - arg1_unw = get_unwidened (arg1, shorter_type); + arg1_unw = get_unwidened (arg1, NULL_TREE); /* If possible, express the comparison in the shorter mode. */ if ((code == EQ_EXPR || code == NE_EXPR || TYPE_UNSIGNED (TREE_TYPE (arg0)) == TYPE_UNSIGNED (shorter_type)) && (TREE_TYPE (arg1_unw) == shorter_type + || (TYPE_PRECISION (shorter_type) + >= TYPE_PRECISION (TREE_TYPE (arg1_unw))) || (TREE_CODE (arg1_unw) == INTEGER_CST && (TREE_CODE (shorter_type) == INTEGER_TYPE || TREE_CODE (shorter_type) == BOOLEAN_TYPE) |