+2005-10-17 Alexey Starovoytov <alexey.starovoytov@sun.com>
+ Ian Lance Taylor <ian@airs.com>
+
+ PR middle-end/23522
+ * fold-const.c (fold_widened_comparison): Do not allow range based
+ constant folding when right operand cannot be unwidened.
+
2005-10-17 Richard Henderson <rth@redhat.com>
* builtins.c (expand_builtin_synchronize): Build a new-style asm
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
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