diff options
author | Jakub Jelinek <jakub@redhat.com> | 2009-03-16 17:07:07 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2009-03-16 17:07:07 +0100 |
commit | 97b4ba9f89565410751f1649dc911f14d0098508 (patch) | |
tree | a6e176d86e17b8e5d2e79857a5dddd49f0ca47f7 | |
parent | 83c191e155257e2a98b6be59bd036a5ad0b7c5ca (diff) | |
download | gcc-97b4ba9f89565410751f1649dc911f14d0098508.zip gcc-97b4ba9f89565410751f1649dc911f14d0098508.tar.gz gcc-97b4ba9f89565410751f1649dc911f14d0098508.tar.bz2 |
re PR tree-optimization/39455 (ICE : in compare_values_warnv, at tree-vrp.c:1073)
PR tree-optimization/39455
* tree-ssa-loop-niter.c (number_of_iterations_lt_to_ne): Fix types
mismatches for POINTER_TYPE_P (type).
(number_of_iterations_le): Likewise.
* gcc.dg/pr39455.c: New test.
From-SVN: r144885
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr39455.c | 13 | ||||
-rw-r--r-- | gcc/tree-ssa-loop-niter.c | 36 |
4 files changed, 56 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1e664d8..44b6795 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2009-03-16 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/39455 + * tree-ssa-loop-niter.c (number_of_iterations_lt_to_ne): Fix types + mismatches for POINTER_TYPE_P (type). + (number_of_iterations_le): Likewise. + 2009-03-16 Hariharan Sandanagobalane <hariharan@picochip.com> * config/picochip/picochip.c: Removed profiling support. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 09cae9b..c0fa09c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-03-16 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/39455 + * gcc.dg/pr39455.c: New test. + 2009-03-13 David Ayers <ayers@fsfe.org> * objc/execute/trivial.m. New test. diff --git a/gcc/testsuite/gcc.dg/pr39455.c b/gcc/testsuite/gcc.dg/pr39455.c new file mode 100644 index 0000000..8e8c670 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr39455.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/39455 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fprefetch-loop-arrays -w" } */ + +void +foo (char *x, unsigned long y, unsigned char *z) +{ + unsigned int c[256], *d; + + for (d = c + 1; d < c + 256; ++d) + *d += d[-1]; + x[--c[z[y]]] = 0; +} diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index c67e638..d657e1a 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -699,8 +699,10 @@ number_of_iterations_lt_to_ne (tree type, affine_iv *iv0, affine_iv *iv1, iv0->base <= iv1->base + MOD. */ if (!iv0->no_overflow && !integer_zerop (mod)) { - bound = fold_build2 (MINUS_EXPR, type, + bound = fold_build2 (MINUS_EXPR, type1, TYPE_MAX_VALUE (type1), tmod); + if (POINTER_TYPE_P (type)) + bound = fold_convert (type, bound); assumption = fold_build2 (LE_EXPR, boolean_type_node, iv1->base, bound); if (integer_zerop (assumption)) @@ -708,6 +710,11 @@ number_of_iterations_lt_to_ne (tree type, affine_iv *iv0, affine_iv *iv1, } if (mpz_cmp (mmod, bnds->below) < 0) noloop = boolean_false_node; + else if (POINTER_TYPE_P (type)) + noloop = fold_build2 (GT_EXPR, boolean_type_node, + iv0->base, + fold_build2 (POINTER_PLUS_EXPR, type, + iv1->base, tmod)); else noloop = fold_build2 (GT_EXPR, boolean_type_node, iv0->base, @@ -723,6 +730,8 @@ number_of_iterations_lt_to_ne (tree type, affine_iv *iv0, affine_iv *iv1, { bound = fold_build2 (PLUS_EXPR, type1, TYPE_MIN_VALUE (type1), tmod); + if (POINTER_TYPE_P (type)) + bound = fold_convert (type, bound); assumption = fold_build2 (GE_EXPR, boolean_type_node, iv0->base, bound); if (integer_zerop (assumption)) @@ -730,6 +739,13 @@ number_of_iterations_lt_to_ne (tree type, affine_iv *iv0, affine_iv *iv1, } if (mpz_cmp (mmod, bnds->below) < 0) noloop = boolean_false_node; + else if (POINTER_TYPE_P (type)) + noloop = fold_build2 (GT_EXPR, boolean_type_node, + fold_build2 (POINTER_PLUS_EXPR, type, + iv0->base, + fold_build1 (NEGATE_EXPR, + type1, tmod)), + iv1->base); else noloop = fold_build2 (GT_EXPR, boolean_type_node, fold_build2 (MINUS_EXPR, type1, @@ -1084,10 +1100,10 @@ number_of_iterations_le (tree type, affine_iv *iv0, affine_iv *iv1, { if (integer_nonzerop (iv0->step)) assumption = fold_build2 (NE_EXPR, boolean_type_node, - iv1->base, TYPE_MAX_VALUE (type1)); + iv1->base, TYPE_MAX_VALUE (type)); else assumption = fold_build2 (NE_EXPR, boolean_type_node, - iv0->base, TYPE_MIN_VALUE (type1)); + iv0->base, TYPE_MIN_VALUE (type)); if (integer_zerop (assumption)) return false; @@ -1097,8 +1113,18 @@ number_of_iterations_le (tree type, affine_iv *iv0, affine_iv *iv1, } if (integer_nonzerop (iv0->step)) - iv1->base = fold_build2 (PLUS_EXPR, type1, - iv1->base, build_int_cst (type1, 1)); + { + if (POINTER_TYPE_P (type)) + iv1->base = fold_build2 (POINTER_PLUS_EXPR, type, iv1->base, + build_int_cst (type1, 1)); + else + iv1->base = fold_build2 (PLUS_EXPR, type1, iv1->base, + build_int_cst (type1, 1)); + } + else if (POINTER_TYPE_P (type)) + iv0->base = fold_build2 (POINTER_PLUS_EXPR, type, iv0->base, + fold_build1 (NEGATE_EXPR, type1, + build_int_cst (type1, 1))); else iv0->base = fold_build2 (MINUS_EXPR, type1, iv0->base, build_int_cst (type1, 1)); |