diff options
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index d22e9c447b3..e23b4e3f711 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9550,21 +9550,31 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) /* ~X + X is -1. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR - && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0) && !TYPE_OVERFLOW_TRAPS (type)) { - t1 = build_int_cst_type (type, -1); - return omit_one_operand (type, t1, arg1); + tree tem = TREE_OPERAND (arg0, 0); + + STRIP_NOPS (tem); + if (operand_equal_p (tem, arg1, 0)) + { + t1 = build_int_cst_type (type, -1); + return omit_one_operand (type, t1, arg1); + } } /* X + ~X is -1. */ if (TREE_CODE (arg1) == BIT_NOT_EXPR - && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0) && !TYPE_OVERFLOW_TRAPS (type)) { - t1 = build_int_cst_type (type, -1); - return omit_one_operand (type, t1, arg0); - } + tree tem = TREE_OPERAND (arg1, 0); + + STRIP_NOPS (tem); + if (operand_equal_p (arg0, tem, 0)) + { + t1 = build_int_cst_type (type, -1); + return omit_one_operand (type, t1, arg0); + } + } /* If we are adding two BIT_AND_EXPR's, both of which are and'ing with a constant, and the two constants have no bits in common, @@ -14558,9 +14568,9 @@ fold_relational_const (enum tree_code code, tree type, tree op0, tree op1) return constant_boolean_node (result, type); } -/* Build an expression for the a clean point containing EXPR with type TYPE. - Don't build a cleanup point expression for EXPR which don't have side - effects. */ +/* If necessary, return a CLEANUP_POINT_EXPR for EXPR with the + indicated TYPE. If no CLEANUP_POINT_EXPR is necessary, return EXPR + itself. */ tree fold_build_cleanup_point_expr (tree type, tree expr) |