diff options
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index d1b59a1..f7bf525 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -10092,7 +10092,7 @@ fold_binary_loc (location_t loc, { /* Convert ~A + 1 to -A. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR - && integer_onep (arg1)) + && integer_each_onep (arg1)) return fold_build1_loc (loc, NEGATE_EXPR, type, fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0))); @@ -10619,9 +10619,8 @@ fold_binary_loc (location_t loc, fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0))); /* Convert -A - 1 to ~A. */ - if (TREE_CODE (type) != COMPLEX_TYPE - && TREE_CODE (arg0) == NEGATE_EXPR - && integer_onep (arg1) + if (TREE_CODE (arg0) == NEGATE_EXPR + && integer_each_onep (arg1) && !TYPE_OVERFLOW_TRAPS (type)) return fold_build1_loc (loc, BIT_NOT_EXPR, type, fold_convert_loc (loc, type, @@ -11384,6 +11383,7 @@ fold_binary_loc (location_t loc, /* Fold (X & 1) ^ 1 as (X & 1) == 0. */ if (TREE_CODE (arg0) == BIT_AND_EXPR + && INTEGRAL_TYPE_P (type) && integer_onep (TREE_OPERAND (arg0, 1)) && integer_onep (arg1)) return fold_build2_loc (loc, EQ_EXPR, type, arg0, @@ -11494,6 +11494,7 @@ fold_binary_loc (location_t loc, /* Fold (X ^ 1) & 1 as (X & 1) == 0. */ if (TREE_CODE (arg0) == BIT_XOR_EXPR + && INTEGRAL_TYPE_P (type) && integer_onep (TREE_OPERAND (arg0, 1)) && integer_onep (arg1)) { @@ -11507,6 +11508,7 @@ fold_binary_loc (location_t loc, } /* Fold ~X & 1 as (X & 1) == 0. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR + && INTEGRAL_TYPE_P (type) && integer_onep (arg1)) { tree tem2; |