Summary: | [4.3 Regression] ICE : in compare_values_warnv, at tree-vrp.c:1073 | ||
---|---|---|---|
Product: | gcc | Reporter: | macius bat <linuxl4> |
Component: | tree-optimization | Assignee: | Richard Biener <rguenth> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | cnstar9988, gcc-bugs, jh |
Priority: | P2 | Keywords: | ice-on-valid-code |
Version: | 4.4.0 | ||
Target Milestone: | 4.3.4 | ||
Host: | x86_64-linux | Target: | x86_64-linux |
Build: | X86_64-PC-LINUX-GNU | Known to work: | 4.1.2 4.2.4 4.4.0 |
Known to fail: | 4.3.3 | Last reconfirmed: | 2009-03-16 08:49:06 |
Attachments: | the source |
Description
macius bat
2009-03-13 12:33:23 UTC
Created attachment 17456 [details]
the source
Confirmed. Works with 4.1 and 4.2. (In reply to comment #2) > Confirmed. Works with 4.1 and 4.2. > I got [hjl@gnu-16 rrs]$ gcc -O2 -fprefetch-loop-array pr39455.c -S cc1: error: unrecognized command line option "-fprefetch-loop-array" [hjl@gnu-16 rrs]$ gcc --version gcc (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7) Is -fprefetch-loop-array a new option in gcc 4.4? s/array/arrays/ This is caused by revision 131502: http://gcc.gnu.org/ml/gcc-cvs/2008-01/msg00263.html http://gcc.gnu.org/ml/gcc-patches/2008-01/msg00539.html Well, exposed rather than caused. Reduced testcase: /* { dg-do compile } */ /* { dg-options "-O2 -fprefetch-loop-arrays" } */ 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; } Subject: Re: [4.3/4.4 Regression] ICE : in compare_values_warnv, at tree-vrp.c:1073 Sent from my iPhone On Mar 16, 2009, at 1:15 AM, "jakub at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org > wrote: > > > ------- Comment #7 from jakub at gcc dot gnu dot org 2009-03-16 > 08:15 ------- > Reduced testcase: > > /* { dg-do compile } */ > /* { dg-options "-O2 -fprefetch-loop-arrays" } */ > > 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; Hmm. Could this be the char-- bug? Where the front-end/gimplifier does not promote that to int? Thanks, Andrew Pinski > > } > > > -- > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39455 > No, this seems to be aprefetch's pass fault, at least in quick skim *.cunroll seems to be ok typewise, while *.aprefetch has: D.1649_44 = &c + 1024; D.1650_43 = (long unsigned int) D.1649_44; if (&c[2] <= D.1650_43) D.1650 is long unsigned int and c is unsigned int c[256], so obviously the comparison above is wrong. Will try to debug it. Seems tree-ssa-loop-niter.c has a lot of p+ issues. The following untested patch fixes just the number_of_iterations_lt_to_ne bugs and fixes this testcase: --- gcc/tree-ssa-loop-niter.c.jj 2009-03-04 20:06:31.000000000 +0100 +++ gcc/tree-ssa-loop-niter.c 2009-03-16 10:30:39.000000000 +0100 @@ -699,8 +699,10 @@ number_of_iterations_lt_to_ne (tree type 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 } 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 { 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 } 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_unary (NEGATE_EXPR, + type1, tmod)), + iv1->base); else noloop = fold_build2 (GT_EXPR, boolean_type_node, fold_build2 (MINUS_EXPR, type1, but e.g. number_of_iterations_le doesn't look correct at all as well. Subject: Bug 39455 Author: jakub Date: Mon Mar 16 16:07:07 2009 New Revision: 144885 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144885 Log: 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. Added: trunk/gcc/testsuite/gcc.dg/pr39455.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-loop-niter.c Fixed on the trunk so far. ping 4.3.4... ping 4.3.4... The PR40087 fix depends on changes from the this fix, thanks! Testing a backport. Fixed. Subject: Bug 39455 Author: rguenth Date: Wed Jun 17 19:45:52 2009 New Revision: 148625 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148625 Log: 2009-06-17 Richard Guenther <rguenther@suse.de> Backport from mainline 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. * gcc.dg/pr39455.c: New test. 2009-05-19 Zdenek Dvorak <ook@ucw.cz> PR tree-optimization/40087 * tree-ssa-loop-niter.c (number_of_iterations_ne_max, number_of_iterations_ne): Rename never_infinite argument. (number_of_iterations_lt_to_ne, number_of_iterations_lt, number_of_iterations_le): Handle pointer-type ivs when exit_must_be_taken is false. (number_of_iterations_cond): Do not always assume that exit_must_be_taken if the control variable is a pointer. * gcc.dg/tree-ssa/pr40087.c: New test. Added: branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/pr39455.c branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/tree-ssa/pr40087.c Modified: branches/gcc-4_3-branch/gcc/ChangeLog branches/gcc-4_3-branch/gcc/testsuite/ChangeLog branches/gcc-4_3-branch/gcc/tree-ssa-loop-niter.c |