tree result;
expr = save_expr (expr);
- result = build3 (COND_EXPR, type,
- build2 (NE_EXPR, boolean_type_node, expr, expr),
- convert (type, integer_zero_node),
- convert_to_integer (type, expr));
-
- result = build3 (COND_EXPR, type,
- build2 (LE_EXPR, boolean_type_node, expr,
- convert (TREE_TYPE (expr), TYPE_MIN_VALUE (type))),
- TYPE_MIN_VALUE (type),
- result);
-
- result = build3 (COND_EXPR, type,
- build2 (GE_EXPR, boolean_type_node, expr,
- convert (TREE_TYPE (expr), TYPE_MAX_VALUE (type))),
- TYPE_MAX_VALUE (type),
- result);
+ result = fold (build3 (COND_EXPR, type,
+ fold (build2 (NE_EXPR, boolean_type_node, expr, expr)),
+ convert (type, integer_zero_node),
+ convert_to_integer (type, expr)));
+
+ result = fold (build3 (COND_EXPR, type,
+ fold (build2 (LE_EXPR, boolean_type_node, expr,
+ convert (TREE_TYPE (expr),
+ TYPE_MIN_VALUE (type)))),
+ TYPE_MIN_VALUE (type),
+ result));
+
+ result = fold (build3 (COND_EXPR, type,
+ fold (build2 (GE_EXPR, boolean_type_node, expr,
+ convert (TREE_TYPE (expr),
+ TYPE_MAX_VALUE (type)))),
+ TYPE_MAX_VALUE (type),
+ result));
return result;
}
return fold (convert_to_boolean (type, expr));
if (code == INTEGER_TYPE)
{
- if (! flag_unsafe_math_optimizations
- && ! flag_emit_class_files
+ if ((really_constant_p (expr)
+ || (! flag_unsafe_math_optimizations
+ && ! flag_emit_class_files))
&& TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE
&& TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT)
return fold (convert_ieee_real_to_integer (type, expr));