diff options
| author | uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-01 10:38:03 +0000 |
|---|---|---|
| committer | uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-01 10:38:03 +0000 |
| commit | b30baf88b62e58b9a6b7bd1af0a996065a89cbbc (patch) | |
| tree | 660004e8d661d3b7d1c08602325e305d0f9f2ef9 | |
| parent | 8528e81f99456ddea2782f6eacb09e0665bd39e7 (diff) | |
| download | ppe42-gcc-b30baf88b62e58b9a6b7bd1af0a996065a89cbbc.tar.gz ppe42-gcc-b30baf88b62e58b9a6b7bd1af0a996065a89cbbc.zip | |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126164 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/ChangeLog | 8 | ||||
| -rw-r--r-- | gcc/fold-const.c | 41 | ||||
| -rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.dg/pr32559.c | 9 |
4 files changed, 44 insertions, 20 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7e576becf2f..2229807eebf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2007-07-01 Uros Bizjak <ubizjak@gmail.com> + + 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. + 2007-06-30 Joseph Myers <joseph@codesourcery.com> * configure.ac: Check for .gnu_attribute on MIPS. @@ -137,7 +143,7 @@ 2006-06-30 Jan Hubicka <jh@suse.cz> - * loop-unroll.c (unroll_loop_runtime_iterations): Unshare newly emit + * loop-unroll.c (unroll_loop_runtime_iterations): Unshare newly emit code. 2006-06-30 Thomas Neumann <tneumann@users.sourceforge.net> diff --git a/gcc/fold-const.c b/gcc/fold-const.c index d806e7afc70..9dfd07fb855 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, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9318ce27d60..ec17942a130 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-067-01 Uros Bizjak <ubizjak@gmail.com> + Volker Reichelt <reichelt@netcologne.de> + + PR middle-end/32559 + * gcc.dg/pr32559.c: New test. + 2007-07-01 Uros Bizjak <ubizjak@gmail.com> PR tree-optimization/25371 diff --git a/gcc/testsuite/gcc.dg/pr32559.c b/gcc/testsuite/gcc.dg/pr32559.c new file mode 100644 index 00000000000..fee1c979073 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr32559.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int __attribute__((vector_size (8))) v; + +void foo() +{ + v += ~v; +} |

