[Bug tree-optimization/41497] [4.5 Regression] apparent integer wrong code bug

2009-10-30 Thread hjl at gcc dot gnu dot org


--- Comment #14 from hjl at gcc dot gnu dot org  2009-10-30 16:05 ---
Subject: Bug 41497

Author: hjl
Date: Fri Oct 30 16:04:41 2009
New Revision: 153759

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=153759
Log:
2009-10-30  H.J. Lu  hongjiu...@intel.com

Backport from mainline:
2009-10-30  Dodji Seketeli  do...@redhat.com

PR c++/41863
* g++.dg/template/sizeof12.C: New test.

2009-10-29  Martin Jambor  mjam...@suse.cz

PR tree-optimization/41775
* g++.dg/torture/pr41775.C: New testcase.

2009-10-28  Jakub Jelinek  ja...@redhat.com

PR debug/41801
* g++.dg/ext/sync-3.C: New test.

2009-10-27  Jakub Jelinek  ja...@redhat.com

PR c++/41020
* g++.dg/lookup/extern-c-redecl5.C: Fix up regexp.

2009-10-26  Jakub Jelinek  ja...@redhat.com

PR bootstrap/41345
* gcc.dg/pr41345.c: New test.

2009-10-26  Dodji Seketeli  do...@redhat.com

PR c++/41785
* g++.dg/cpp0x/variadic96.C: New test.

2009-10-26  Dodji Seketeli  do...@redhat.com

PR c++/41020
* g++.dg/lookup/extern-c-redecl2.C: New test.
* g++.dg/lookup/extern-c-redecl3.C: Likewise.
* g++.dg/lookup/extern-c-redecl4.C: Likewise.
* g++.dg/lookup/extern-c-redecl5.C: Likewise.

2009-10-23  Joseph Myers  jos...@codesourcery.com

PR c/40033
* gcc.dg/noncompile/pr40033-1.c: New test.

2009-10-23  Joseph Myers  jos...@codesourcery.com

PR c/41673
* gcc.dg/Wstrict-aliasing-bogus-vla-1.c: New test.

2009-10-21  Sebastian Pop  sebastian@amd.com

PR tree-optimization/41497
* gcc.dg/tree-ssa/pr41497.c: New.

Added:
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/variadic96.C
  - copied unchanged from r153757,
trunk/gcc/testsuite/g++.dg/cpp0x/variadic96.C
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/ext/sync-3.C
  - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/ext/sync-3.C
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl2.C
  - copied unchanged from r153757,
trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl2.C
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
  - copied unchanged from r153757,
trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
  - copied unchanged from r153757,
trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl5.C
  - copied unchanged from r153757,
trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl5.C
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/sizeof12.C
  - copied unchanged from r153757,
trunk/gcc/testsuite/g++.dg/template/sizeof12.C
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr41775.C
  - copied unchanged from r153757,
trunk/gcc/testsuite/g++.dg/torture/pr41775.C
branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-vla-1.c
  - copied unchanged from r153758,
trunk/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-vla-1.c
branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/noncompile/pr40033-1.c
  - copied unchanged from r153758,
trunk/gcc/testsuite/gcc.dg/noncompile/pr40033-1.c
branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr41345.c
  - copied unchanged from r153757, trunk/gcc/testsuite/gcc.dg/pr41345.c
branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/tree-ssa/pr41497.c
  - copied unchanged from r153758,
trunk/gcc/testsuite/gcc.dg/tree-ssa/pr41497.c
Modified:
branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


-- 


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



[Bug tree-optimization/41497] [4.5 Regression] apparent integer wrong code bug

2009-10-21 Thread spop at gcc dot gnu dot org


--- Comment #12 from spop at gcc dot gnu dot org  2009-10-21 23:05 ---
Subject: Bug 41497

Author: spop
Date: Wed Oct 21 23:05:39 2009
New Revision: 153441

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=153441
Log:
PR tree-optimization/41497
* tree-scalar-evolution.c (analyze_evolution_in_loop): Return
chrec_dont_know if the evolution function returned by follow_ssa_edge
is constant in the analyzed loop and is not compatible with the
initial value before the loop.
* tree-chrec.h (no_evolution_in_loop_p): Call STRIP_NOPS.

* gcc.dg/tree-ssa/pr41497.c: New.


Added:
trunk/gcc/testsuite/gcc.dg/tree-ssa/pr41497.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-chrec.h
trunk/gcc/tree-scalar-evolution.c


-- 


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



[Bug tree-optimization/41497] [4.5 Regression] apparent integer wrong code bug

2009-10-21 Thread spop at gcc dot gnu dot org


--- Comment #13 from spop at gcc dot gnu dot org  2009-10-21 23:10 ---
Fixed.

This bug is potentially latent in older branches.
Should I test it in the 4.4 branch as well?


-- 

spop at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


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



[Bug tree-optimization/41497] [4.5 Regression] apparent integer wrong code bug

2009-10-20 Thread spop at gcc dot gnu dot org


--- Comment #10 from spop at gcc dot gnu dot org  2009-10-20 21:53 ---
Subject: Re:  [4.5 Regression] apparent integer 
wrong code bug

 The problem is that we follow SSA edges into loops that may not be executed.

It is correct to follow SSA edges in loops that may not execute, as we
compute a symbolic expression of the evolution.

The error is that we are not careful enough in the use of this
symbolic information: in analyze_evolution_in_loop we are given the
loop_phi_node: a_lsm.6_15 = PHI a_lsm.6_18(3), a_lsm.6_20(4) and its
initial value init_cond: a_lsm.6_18.

follow_ssa_edge returns an evolution function ev_fn that could be
incompatible with the initial value:

(unsigned int) (short unsigned int) a_lsm.6_18;

The attached patch fixes the problem by returning don't know when
init_cond is not equal to ev_fn when no_evolution_in_loop_p manages to
prove that ev_fn is invariant in the loop.

Sebastian


--- Comment #11 from spop at gcc dot gnu dot org  2009-10-20 21:53 ---
Created an attachment (id=18847)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18847action=view)


-- 


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



[Bug tree-optimization/41497] [4.5 Regression] apparent integer wrong code bug

2009-10-12 Thread ebotcazou at gcc dot gnu dot org


--- Comment #7 from ebotcazou at gcc dot gnu dot org  2009-10-12 17:59 
---
 It is caused by revision 147716:
 
 http://gcc.gnu.org/ml/gcc-cvs/2009-05/msg00693.html

Yep, but it's Richard's fault. ;-)  The bug is exposed by the change requested
in http://gcc.gnu.org/ml/gcc-patches/2009-05/msg01227.html so I won't go beyond
suggesting the following partial reversion

Index: tree-scalar-evolution.c
===
--- tree-scalar-evolution.c (revision 152647)
+++ tree-scalar-evolution.c (working copy)
@@ -1159,7 +1159,7 @@ follow_ssa_edge_expr (struct loop *loop,

   switch (code)
 {
-CASE_CONVERT:
+case NOP_EXPR:
   /* This assignment is under the form a_1 = (cast) rhs.  */
   res = follow_ssa_edge_expr (loop, at_stmt, TREE_OPERAND (expr, 0),
  halting_phi, evolution_of_loop, limit);
@@ -1222,7 +1222,7 @@ follow_ssa_edge_in_rhs (struct loop *loo

   switch (code)
 {
-CASE_CONVERT:
+case NOP_EXPR:
   /* This assignment is under the form a_1 = (cast) rhs.  */
   res = follow_ssa_edge_expr (loop, stmt, gimple_assign_rhs1 (stmt),
  halting_phi, evolution_of_loop, limit);

But I also think that the real problem is elsewhere.


-- 


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



[Bug tree-optimization/41497] [4.5 Regression] apparent integer wrong code bug

2009-10-12 Thread rguenth at gcc dot gnu dot org


--- Comment #8 from rguenth at gcc dot gnu dot org  2009-10-12 20:23 ---
Eh, indeed if that fixes it the bug is elsewhere.  I suggest to not apply this
partial reversion until we know better.


-- 


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



[Bug tree-optimization/41497] [4.5 Regression] apparent integer wrong code bug

2009-10-12 Thread rguenth at gcc dot gnu dot org


--- Comment #9 from rguenth at gcc dot gnu dot org  2009-10-12 20:24 ---
The problem is that we follow SSA edges into loops that may not be executed.
Sebastian - how are we supposed to deal with this case?


-- 


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



[Bug tree-optimization/41497] [4.5 Regression] apparent integer wrong code bug

2009-10-11 Thread rguenth at gcc dot gnu dot org


--- Comment #3 from rguenth at gcc dot gnu dot org  2009-10-11 11:56 ---
The key is IMHO that the inner loop does not have its loop header copied.
This confuses SCEV enough to think that a = (unsigned short)a is always
executed.  LIM is necessary to promote all the memory to SSA names, the
interesting CHREC that gets wrong is

bb 3:
..
  a_lsm.6_18 = 0x0fff3;
  goto bb 5;

bb 4:
...
  a.1_2 = a_lsm.6_15;
  D.2006_3 = (short unsigned int) a.1_2;
  a.2_4 = (unsigned int) D.2006_3;
  a_lsm.6_20 = a.2_4;

bb 5:
  # a_lsm.6_15 = PHI a_lsm.6_18(3), a_lsm.6_20(4)
...
  a.1_1 = a_lsm.6_15;
  if (a.1_1 == 0)
goto bb 4;
  else
goto bb 6;

 bb 6:
...
-  # a_lsm.6_27 = PHI a_lsm.6_15(5)


 bb 8:
-  # a_lsm.6_28 = PHI a_lsm.6_27(6)
-  a = a_lsm.6_28;
+  a = 65523;

where interestingly a_lsm.6_15 isn't computed wrong.


Testcase, fails at -Os:

extern void abort (void);

unsigned int a;
int b, c;

void
foo (void)
{
  b = 0;
  do {
for (a = -13; a == 0; a = (unsigned short)a)
  c = 1;
b++;
  } while (b == 0);
}

int
main ()
{
  foo ();
  if (a != -13)
abort ();
  return 0;
}


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||spop at gcc dot gnu dot org


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



[Bug tree-optimization/41497] [4.5 Regression] apparent integer wrong code bug

2009-10-11 Thread rguenth at gcc dot gnu dot org


--- Comment #4 from rguenth at gcc dot gnu dot org  2009-10-11 11:56 ---
Sebastian, can you have a look?


-- 


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



[Bug tree-optimization/41497] [4.5 Regression] apparent integer wrong code bug

2009-10-11 Thread hjl dot tools at gmail dot com


--- Comment #5 from hjl dot tools at gmail dot com  2009-10-11 16:59 ---
Revision 147714 is OK and revision 147717 is bad.


-- 

hjl dot tools at gmail dot com changed:

   What|Removed |Added

 CC||hjl dot tools at gmail dot
   ||com


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



[Bug tree-optimization/41497] [4.5 Regression] apparent integer wrong code bug

2009-10-11 Thread hjl dot tools at gmail dot com


--- Comment #6 from hjl dot tools at gmail dot com  2009-10-11 19:34 ---
It is caused by revision 147716:

http://gcc.gnu.org/ml/gcc-cvs/2009-05/msg00693.html


-- 

hjl dot tools at gmail dot com changed:

   What|Removed |Added

 CC||ebotcazou at gcc dot gnu dot
   ||org


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



[Bug tree-optimization/41497] [4.5 Regression] apparent integer wrong code bug

2009-09-30 Thread rguenth at gcc dot gnu dot org


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

   Priority|P3  |P1


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



[Bug tree-optimization/41497] [4.5 Regression] apparent integer wrong code bug

2009-09-29 Thread rguenth at gcc dot gnu dot org


--- Comment #2 from rguenth at gcc dot gnu dot org  2009-09-29 09:51 ---
Thus, confirmed.


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
  Component|c   |tree-optimization
 Ever Confirmed|0   |1
   Keywords||wrong-code
  Known to work||4.3.4 4.4.1
   Last reconfirmed|-00-00 00:00:00 |2009-09-29 09:51:50
   date||
Summary|apparent integer wrong code |[4.5 Regression] apparent
   |bug |integer wrong code bug
   Target Milestone|--- |4.5.0
Version|unknown |4.5.0


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