diff options
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/fold-const.c | 14 | ||||
-rw-r--r-- | gcc/java/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/java/builtins.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/const7.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr36227.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/foldaddr-1.c | 2 | ||||
-rw-r--r-- | gcc/tree-ssa-address.c | 6 |
9 files changed, 46 insertions, 22 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3c2457d84e6..f3c186ee1d7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2009-01-16 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/38835 + PR middle-end/36227 + * fold-const.c (fold_binary): Remove PTR + INT -> (INT)(PTR p+ INT) + and INT + PTR -> (INT)(PTR p+ INT) folding. + * tree-ssa-address.c (create_mem_ref): Properly use POINTER_PLUS_EXPR. + 2009-01-16 Adam Nemet <anemet@caviumnetworks.com> PR target/38554 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 32863e6b4e8..eb7d7c91210 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9864,20 +9864,6 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) return NULL_TREE; case PLUS_EXPR: - /* PTR + INT -> (INT)(PTR p+ INT) */ - if (POINTER_TYPE_P (TREE_TYPE (arg0)) - && INTEGRAL_TYPE_P (TREE_TYPE (arg1))) - return fold_convert (type, fold_build2 (POINTER_PLUS_EXPR, - TREE_TYPE (arg0), - arg0, - fold_convert (sizetype, arg1))); - /* INT + PTR -> (INT)(PTR p+ INT) */ - if (POINTER_TYPE_P (TREE_TYPE (arg1)) - && INTEGRAL_TYPE_P (TREE_TYPE (arg0))) - return fold_convert (type, fold_build2 (POINTER_PLUS_EXPR, - TREE_TYPE (arg1), - arg1, - fold_convert (sizetype, arg0))); /* A + (-B) -> A - B */ if (TREE_CODE (arg1) == NEGATE_EXPR) return fold_build2 (MINUS_EXPR, type, diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index a1773802748..dd696e689da 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +2009-01-16 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/38835 + PR middle-end/36227 + * builtins.c (build_addr_sum): Use POINTER_PLUS_EXPR. + 2008-12-05 Sebastian Pop <sebastian.pop@amd.com> PR bootstrap/38262 diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c index a760def7748..c46241b7a81 100644 --- a/gcc/java/builtins.c +++ b/gcc/java/builtins.c @@ -265,9 +265,10 @@ static tree build_addr_sum (tree type, tree addr, tree offset) { tree ptr_type = build_pointer_type (type); - return fold_build2 (PLUS_EXPR, - ptr_type, - fold_convert (ptr_type, addr), offset); + return fold_build2 (POINTER_PLUS_EXPR, + ptr_type, + fold_convert (ptr_type, addr), + fold_convert (sizetype, offset)); } /* Make sure that this-arg is non-NULL. This is a security check. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4a41a218ab1..a7084b7e850 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2009-01-16 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/38835 + PR middle-end/36227 + * gcc.c-torture/execute/pr36227.c: New testcase. + * gcc.dg/tree-ssa/foldaddr-1.c: XFAIL. + * g++.dg/init/const7.C: Likewise. + 2009-01-16 Adam Nemet <anemet@caviumnetworks.com> PR target/38554 diff --git a/gcc/testsuite/g++.dg/init/const7.C b/gcc/testsuite/g++.dg/init/const7.C index 18d04625db2..348bd58d690 100644 --- a/gcc/testsuite/g++.dg/init/const7.C +++ b/gcc/testsuite/g++.dg/init/const7.C @@ -9,5 +9,5 @@ short offsets[1] = { // This ensures that we get a dump whether or not the bug is present. void fn() { } -// { dg-final { scan-tree-dump-not "initialization" "gimple" } } +// { dg-final { scan-tree-dump-not "initialization" "gimple" { xfail *-*-* } } } // { dg-final { cleanup-tree-dump "gimple" } } diff --git a/gcc/testsuite/gcc.c-torture/execute/pr36227.c b/gcc/testsuite/gcc.c-torture/execute/pr36227.c new file mode 100644 index 00000000000..355adf4c5df --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr36227.c @@ -0,0 +1,15 @@ +#include <stdint.h> +extern void abort (void); +int main() +{ + int i = 1; + int *p = &i; + uintptr_t iptr; + + iptr = (uintptr_t)p - (uintptr_t)&iptr; + p = (int *)((uintptr_t)&iptr + iptr); + if (*p != 1) + abort (); + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/foldaddr-1.c b/gcc/testsuite/gcc.dg/tree-ssa/foldaddr-1.c index a92498eb1f6..2d8ccae2777 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/foldaddr-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/foldaddr-1.c @@ -11,6 +11,6 @@ int foo(char *b) /* Folding should have determined that the two addresses were not identical and thus collapsed the function into a trivial "return 0". */ -/* { dg-final { scan-tree-dump-times "return 0" 1 "original"} } */ +/* { dg-final { scan-tree-dump-times "return 0" 1 "original" { xfail *-*-* } } */ /* { dg-final { cleanup-tree-dump "original" } } */ diff --git a/gcc/tree-ssa-address.c b/gcc/tree-ssa-address.c index df4f5c9296f..da236ffd5a9 100644 --- a/gcc/tree-ssa-address.c +++ b/gcc/tree-ssa-address.c @@ -619,9 +619,9 @@ create_mem_ref (gimple_stmt_iterator *gsi, tree type, aff_tree *addr, { atype = TREE_TYPE (tmp); parts.base = force_gimple_operand_gsi (gsi, - fold_build2 (PLUS_EXPR, atype, - fold_convert (atype, parts.base), - tmp), + fold_build2 (POINTER_PLUS_EXPR, atype, + tmp, + fold_convert (sizetype, parts.base)), true, NULL_TREE, true, GSI_SAME_STMT); } else |