diff options
author | Alexey Starovoytov <alexey.starovoytov@sun.com> | 2005-10-18 03:16:21 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2005-10-18 03:16:21 +0000 |
commit | 1630e763dc5319fd41fa5befde95173439d14de7 (patch) | |
tree | e871f3f34d248055c32dd92bd09a939c84f28016 /gcc/fold-const.c | |
parent | 74395677b78fbb5ce35c444f5977b087ebe1a759 (diff) | |
download | gcc-1630e763dc5319fd41fa5befde95173439d14de7.zip gcc-1630e763dc5319fd41fa5befde95173439d14de7.tar.gz gcc-1630e763dc5319fd41fa5befde95173439d14de7.tar.bz2 |
re PR middle-end/23522 (fold_widened_comparison bug)
PR middle-end/23522
* fold-const.c (fold_widened_comparison): Do not allow range based
constant folding when right operand cannot be unwidened.
Co-Authored-By: Ian Lance Taylor <ian@airs.com>
From-SVN: r105536
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 015930e..a6aa1df 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -6250,8 +6250,6 @@ fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1) return NULL_TREE; arg1_unw = get_unwidened (arg1, shorter_type); - if (!arg1_unw) - return NULL_TREE; /* If possible, express the comparison in the shorter mode. */ if ((code == EQ_EXPR || code == NE_EXPR @@ -6264,7 +6262,9 @@ fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1) return fold_build2 (code, type, arg0_unw, fold_convert (shorter_type, arg1_unw)); - if (TREE_CODE (arg1_unw) != INTEGER_CST) + if (TREE_CODE (arg1_unw) != INTEGER_CST + || TREE_CODE (shorter_type) != INTEGER_TYPE + || !int_fits_type_p (arg1_unw, shorter_type)) return NULL_TREE; /* If we are comparing with the integer that does not fit into the range |