[Bug tree-optimization/46693] incorrect code generation with -O2 optimization enabled

2012-01-12 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46693

Andrew Pinski pinskia at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED

--- Comment #15 from Andrew Pinski pinskia at gcc dot gnu.org 2012-01-12 
20:31:24 UTC ---
Fixed so closing as such.


[Bug tree-optimization/46693] incorrect code generation with -O2 optimization enabled

2010-12-14 Thread ramana at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46693

Ramana Radhakrishnan ramana at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|NEW
  Known to work||4.3.5, 4.4.6
  Known to fail||4.5.1

--- Comment #11 from Ramana Radhakrishnan ramana at gcc dot gnu.org 
2010-12-14 09:27:58 UTC ---
So the problem on trunk atleast seems to be in gimple-fold 

maybe_fold_or_comparisons and friends where all the comparisons are folded out
into a single boolean node of 1 where ideally the result of the basic block
should be reduced to the (c = 31)  (x != 9) check . The other 2 equality
comparisons are superfluous. 

I won't be able to look at this for a couple of days - hence unassigning
myself.


The problem for this file goes away with -fno-tree-vrp but that's a heavy
weight work around.



cheers
Ramana


[Bug tree-optimization/46693] incorrect code generation with -O2 optimization enabled

2010-12-14 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46693

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #12 from Jakub Jelinek jakub at gcc dot gnu.org 2010-12-14 
10:06:52 UTC ---
Maybe dup of PR46909?


[Bug tree-optimization/46693] incorrect code generation with -O2 optimization enabled

2010-12-14 Thread ramana at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46693

--- Comment #13 from Ramana Radhakrishnan ramana at gcc dot gnu.org 
2010-12-14 12:07:54 UTC ---
(In reply to comment #12)
 Maybe dup of PR46909?

I can verify that the fix for PR46909 fixes the issue on trunk.

I'm looking into 4.5 branch right now.


cheers
Ramana


[Bug tree-optimization/46693] incorrect code generation with -O2 optimization enabled

2010-12-14 Thread ramana at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46693

--- Comment #14 from Ramana Radhakrishnan ramana at gcc dot gnu.org 
2010-12-14 12:13:00 UTC ---
It doesn't seem to fail for me with the RC for GCC 4.5.2

with -march=armv5te -mthumb
 -march=armv5te
 -march=armv7-a
 -march=armv7-a -mthumb

at -O2, -O3 and -Os


[Bug tree-optimization/46693] incorrect code generation with -O2 optimization enabled

2010-12-13 Thread ramana at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46693

Ramana Radhakrishnan ramana at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
  Component|target  |tree-optimization

--- Comment #9 from Ramana Radhakrishnan ramana at gcc dot gnu.org 2010-12-13 
10:53:31 UTC ---
On trunk 

vrp converts the IR from :


bb 3:
  c_5 = D.2034_4;
  D.2026_6 = D.2034_4 == 13;
  D.2027_7 = D.2034_4 == 10;
  D.2028_8 = D.2026_6 || D.2027_7;
  if (D.2028_8 != 0)
goto bb 7;
  else
goto bb 4;

bb 4:
  D.2030_9 = D.2034_4 = 31;
  D.2031_10 = D.2034_4 != 9;
  D.2032_11 = D.2030_9  D.2031_10;
  if (D.2032_11 != 0)
goto bb 7;
  else
goto bb 5;

bb 5:
  str_12 = str_1 + 1;

bb 6:
  # str_1 = PHI str_3(D)(2), str_12(5)
  D.2034_4 = *str_1;
  if (D.2034_4 != 0)
goto bb 3;
  else
goto bb 7;

bb 7:
  # D.2033_2 = PHI 0(4), 1(6), 0(3)
  return D.2033_2;


to

bb 3:
  c_5 = D.2034_4;
  D.2026_6 = D.2034_4 == 13;
  D.2027_7 = D.2034_4 == 10;
  D.2028_8 = D.2026_6 | D.2027_7;
  if (D.2028_8 != 0)
goto bb 7;
  else
goto bb 4;

bb 4:
  D.2030_9 = D.2034_4 = 31;
  D.2031_10 = D.2034_4 != 9;
  D.2032_11 = D.2030_9  D.2031_10;
  if (D.2032_11 != 0)
goto bb 7;
  else
goto bb 5;

bb 5:
  str_12 = str_1 + 1;

bb 6:
  # str_1 = PHI str_3(D)(2), str_12(5)
  D.2034_4 = *str_1;
  if (D.2034_4 != 0)
goto bb 3;
  else
goto bb 7;

bb 7:
  # D.2033_2 = PHI 0(4), 1(6), 0(3)
  return D.2033_2;

After a while ifcombine comes along and removes basic block 5 and merges blocks
3 and 4 into 1 basic block because it thinks that the 


optimizing two comparisons to 1
Merging blocks 3 and 4
Removing basic block 5

and converts this to this form: 

bb 2:
  goto bb 4;


bb 3:
  D.2026_6 = D.2034_4 == 13;
  D.2027_7 = D.2034_4 == 10;
  D.2028_8 = D.2026_6 | D.2027_7;
  D.2030_9 = D.2034_4 = 31;
  D.2031_10 = D.2034_4 != 9;
  D.2032_11 = D.2030_9  D.2031_10;
  goto bb 5;

bb 4:
Invalid sum of incoming frequencies 873, should be 1
  # str_1 = PHI str_3(D)(2)
  D.2034_4 = *str_1;
  if (D.2034_4 != 0)
goto bb 3;
  else
goto bb 5;

bb 5:
Invalid sum of incoming frequencies 1, should be 873
  # D.2033_2 = PHI 0(3), 1(4)
  return D.2033_2;


[Bug tree-optimization/46693] incorrect code generation with -O2 optimization enabled

2010-12-13 Thread ramana at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46693

--- Comment #10 from Ramana Radhakrishnan ramana at gcc dot gnu.org 
2010-12-13 14:11:13 UTC ---
(In reply to comment #4)
 Works for me on x86_64-darwin.

Fails for me on x86_64 -linux with trunk as of today. 

Ramana