[Bug tree-optimization/39455] [4.3/4.4 Regression] ICE : in compare_values_warnv, at tree-vrp.c:1073

2009-03-16 Thread jakub at gcc dot gnu dot org


--- 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;
}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39455



[Bug tree-optimization/39455] [4.3/4.4 Regression] ICE : in compare_values_warnv, at tree-vrp.c:1073

2009-03-16 Thread pinskia at gmail dot com


--- Comment #8 from pinskia at gmail dot com  2009-03-16 08:28 ---
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-bugzi...@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



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39455



[Bug tree-optimization/39455] [4.3/4.4 Regression] ICE : in compare_values_warnv, at tree-vrp.c:1073

2009-03-16 Thread jakub at gcc dot gnu dot org


--- Comment #9 from jakub at gcc dot gnu dot org  2009-03-16 08:49 ---
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.


-- 

jakub at gcc dot gnu dot org changed:

   What|Removed |Added

 AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
   |dot org |
 Status|NEW |ASSIGNED
   Last reconfirmed|2009-03-13 14:03:54 |2009-03-16 08:49:06
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39455



[Bug tree-optimization/39455] [4.3/4.4 Regression] ICE : in compare_values_warnv, at tree-vrp.c:1073

2009-03-16 Thread jakub at gcc dot gnu dot org


--- Comment #10 from jakub at gcc dot gnu dot org  2009-03-16 09:43 ---
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.jj2009-03-04 20:06:31.0 +0100
+++ gcc/tree-ssa-loop-niter.c   2009-03-16 10:30:39.0 +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.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39455



[Bug tree-optimization/39455] [4.3/4.4 Regression] ICE : in compare_values_warnv, at tree-vrp.c:1073

2009-03-16 Thread jakub at gcc dot gnu dot org


--- Comment #11 from jakub at gcc dot gnu dot org  2009-03-16 16:07 ---
Subject: Bug 39455

Author: jakub
Date: Mon Mar 16 16:07:07 2009
New Revision: 144885

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=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


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39455



[Bug tree-optimization/39455] [4.3/4.4 Regression] ICE : in compare_values_warnv, at tree-vrp.c:1073

2009-03-13 Thread rguenth at gcc dot gnu dot org


--- Comment #2 from rguenth at gcc dot gnu dot org  2009-03-13 14:03 ---
Confirmed.  Works with 4.1 and 4.2.


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
  Component|middle-end  |tree-optimization
 Ever Confirmed|0   |1
   Keywords||ice-on-valid-code
  Known to fail||4.3.3 4.4.0
  Known to work||4.1.2 4.2.4
   Last reconfirmed|-00-00 00:00:00 |2009-03-13 14:03:54
   date||
Summary|ICE : in|[4.3/4.4 Regression] ICE :
   |compare_values_warnv, at|in compare_values_warnv, at
   |tree-vrp.c:1073 |tree-vrp.c:1073
   Target Milestone|--- |4.3.4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39455



[Bug tree-optimization/39455] [4.3/4.4 Regression] ICE : in compare_values_warnv, at tree-vrp.c:1073

2009-03-13 Thread hjl dot tools at gmail dot com


--- Comment #3 from hjl dot tools at gmail dot com  2009-03-13 14:43 ---
(In reply to comment #2)
 Confirmed.  Works with 4.1 and 4.2.
 

I got

[...@gnu-16 rrs]$ gcc -O2 -fprefetch-loop-array pr39455.c -S
cc1: error: unrecognized command line option -fprefetch-loop-array
[...@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?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39455



[Bug tree-optimization/39455] [4.3/4.4 Regression] ICE : in compare_values_warnv, at tree-vrp.c:1073

2009-03-13 Thread jakub at gcc dot gnu dot org


--- Comment #4 from jakub at gcc dot gnu dot org  2009-03-13 14:57 ---
s/array/arrays/


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39455



[Bug tree-optimization/39455] [4.3/4.4 Regression] ICE : in compare_values_warnv, at tree-vrp.c:1073

2009-03-13 Thread hjl dot tools at gmail dot com


--- Comment #5 from hjl dot tools at gmail dot com  2009-03-13 16:38 ---
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


-- 

hjl dot tools at gmail dot com changed:

   What|Removed |Added

 CC||jh at suse dot cz


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39455



[Bug tree-optimization/39455] [4.3/4.4 Regression] ICE : in compare_values_warnv, at tree-vrp.c:1073

2009-03-13 Thread rguenth at gcc dot gnu dot org


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

   Priority|P3  |P2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39455