+2014-11-03 Richard Biener <rguenther@suse.de>
+
+ * match.pd: Add two abs patterns. Announce tree_expr_nonnegative_p.
+ Also drop bogus FLOAT_EXPR and FIX_TRUNC_EXPR.
+ * fold-const.c (fold_unary_loc): Remove them here.
+ (tree_unary_nonnegative_warnv_p): Use CASE_CONVERT.
+ * gimple-fold.c (fold_gimple_assign): Remove now obsolete
+ GIMPLE_UNARY_RHS case.
+ (gimple_fold_stmt_to_constant_1): Likewise.
+ (replace_stmt_with_simplification): Fix inverted comparison.
+
2014-11-03 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/60770
case ABS_EXPR:
if (TREE_CODE (arg0) == INTEGER_CST || TREE_CODE (arg0) == REAL_CST)
return fold_abs_const (arg0, type);
- else if (TREE_CODE (arg0) == NEGATE_EXPR)
- return fold_build1_loc (loc, ABS_EXPR, type, TREE_OPERAND (arg0, 0));
/* Convert fabs((double)float) into (double)fabsf(float). */
else if (TREE_CODE (arg0) == NOP_EXPR
&& TREE_CODE (type) == REAL_TYPE)
/* ABS_EXPR<ABS_EXPR<x>> = ABS_EXPR<x> even if flag_wrapv is on. */
else if (TREE_CODE (arg0) == ABS_EXPR)
return arg0;
- else if (tree_expr_nonnegative_p (arg0))
- return arg0;
/* Strip sign ops from argument. */
if (TREE_CODE (type) == REAL_TYPE)
break;
case GIMPLE_UNARY_RHS:
- {
- tree rhs = gimple_assign_rhs1 (stmt);
-
- result = fold_unary_loc (loc, subcode, gimple_expr_type (stmt), rhs);
- if (result)
- {
- /* If the operation was a conversion do _not_ mark a
- resulting constant with TREE_OVERFLOW if the original
- constant was not. These conversions have implementation
- defined behavior and retaining the TREE_OVERFLOW flag
- here would confuse later passes such as VRP. */
- if (CONVERT_EXPR_CODE_P (subcode)
- && TREE_CODE (result) == INTEGER_CST
- && TREE_CODE (rhs) == INTEGER_CST)
- TREE_OVERFLOW (result) = TREE_OVERFLOW (rhs);
-
- STRIP_USELESS_TYPE_CONVERSION (result);
- if (valid_gimple_rhs_p (result))
- return result;
- }
- }
break;
case GIMPLE_BINARY_RHS:
&& rcode.is_tree_code ())
{
if (!inplace
- || gimple_num_ops (stmt) <= get_gimple_rhs_num_ops (rcode))
+ || gimple_num_ops (stmt) > get_gimple_rhs_num_ops (rcode))
{
maybe_build_generic_op (rcode,
TREE_TYPE (gimple_assign_lhs (stmt)),
}
case GIMPLE_UNARY_RHS:
- {
- /* Handle unary operators that can appear in GIMPLE form.
- Note that we know the single operand must be a constant,
- so this should almost always return a simplified RHS. */
- tree op0 = (*valueize) (gimple_assign_rhs1 (stmt));
-
- return
- fold_unary_ignore_overflow_loc (loc, subcode,
- gimple_expr_type (stmt), op0);
- }
+ return NULL_TREE;
case GIMPLE_BINARY_RHS:
{
(define_predicates
integer_onep integer_zerop integer_all_onesp
real_zerop real_onep
- CONSTANT_CLASS_P)
+ CONSTANT_CLASS_P
+ tree_expr_nonnegative_p)
/* Simplifications of operations with one constant operand and
(bitop @0 @0)
(non_lvalue @0)))
+(simplify
+ (abs (negate @0))
+ (abs @0))
+(simplify
+ (abs tree_expr_nonnegative_p@0)
+ @0)
+
/* Simplifications of conversions. */
/* Basic strip-useless-type-conversions / strip_nops. */
-(for cvt (convert view_convert)
+(for cvt (convert view_convert float fix_trunc)
(simplify
(cvt @0)
(if ((GIMPLE && useless_type_conversion_p (type, TREE_TYPE (@0)))