diff options
author | Uros Bizjak <uros@gcc.gnu.org> | 2007-07-01 12:38:03 +0200 |
---|---|---|
committer | Uros Bizjak <uros@gcc.gnu.org> | 2007-07-01 12:38:03 +0200 |
commit | c22f6d33be6f0743c78b9d3728c2aecb5c1a5f67 (patch) | |
tree | 660004e8d661d3b7d1c08602325e305d0f9f2ef9 /gcc/fold-const.c | |
parent | 344c77be01b87169aa6c588b559228e67533508a (diff) | |
download | gcc-c22f6d33be6f0743c78b9d3728c2aecb5c1a5f67.zip gcc-c22f6d33be6f0743c78b9d3728c2aecb5c1a5f67.tar.gz gcc-c22f6d33be6f0743c78b9d3728c2aecb5c1a5f67.tar.bz2 |
re PR middle-end/32559 (ICE with vector arithmetic)
PR middle-end/32559
* fold-const.c (fold-binary) [PLUS_EXPR]: Convert ~X + X to 1 or
X + ~X to 1 only for INTEGRAL_TYPE_P type.
testsuite/ChangeLog:
PR middle-end/32559
* gcc.dg/pr32559.c: New test.
From-SVN: r126164
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index d806e7a..9dfd07f 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9270,27 +9270,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) return fold_build2 (MINUS_EXPR, type, fold_convert (type, arg1), fold_convert (type, TREE_OPERAND (arg0, 0))); - /* Convert ~A + 1 to -A. */ - if (INTEGRAL_TYPE_P (type) - && TREE_CODE (arg0) == BIT_NOT_EXPR - && integer_onep (arg1)) - return fold_build1 (NEGATE_EXPR, type, TREE_OPERAND (arg0, 0)); - - /* Handle (A1 * C1) + (A2 * C2) with A1, A2 or C1, C2 being the - same or one. */ - if ((TREE_CODE (arg0) == MULT_EXPR - || TREE_CODE (arg1) == MULT_EXPR) - && (!FLOAT_TYPE_P (type) || flag_unsafe_math_optimizations)) - { - tree tem = fold_plusminus_mult_expr (code, type, arg0, arg1); - if (tem) - return tem; - } - if (! FLOAT_TYPE_P (type)) + if (INTEGRAL_TYPE_P (type)) { - if (integer_zerop (arg1)) - return non_lvalue (fold_convert (type, arg0)); + /* Convert ~A + 1 to -A. */ + if (TREE_CODE (arg0) == BIT_NOT_EXPR + && integer_onep (arg1)) + return fold_build1 (NEGATE_EXPR, type, TREE_OPERAND (arg0, 0)); /* ~X + X is -1. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR @@ -9319,6 +9305,23 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) return omit_one_operand (type, t1, arg0); } } + } + + /* Handle (A1 * C1) + (A2 * C2) with A1, A2 or C1, C2 being the + same or one. */ + if ((TREE_CODE (arg0) == MULT_EXPR + || TREE_CODE (arg1) == MULT_EXPR) + && (!FLOAT_TYPE_P (type) || flag_unsafe_math_optimizations)) + { + tree tem = fold_plusminus_mult_expr (code, type, arg0, arg1); + if (tem) + return tem; + } + + if (! FLOAT_TYPE_P (type)) + { + if (integer_zerop (arg1)) + return non_lvalue (fold_convert (type, 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, |