This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/13869] [tree-ssa] wrong code with a simple loop


------- Additional Comments From steven at gcc dot gnu dot org  2004-01-28 21:21 -------
With optimization we also return 0 AFAICT. 
Something looks strange in DOM1, but the results look OK. 
 
After DCE1 we have the following tree: 
 
main () 
{ 
  int i; 
  int my_bool; 
 
  # BLOCK 0 
  # PRED: ENTRY (fallthru) 
  my_bool_4 = 1; 
  i_5 = 0; 
  goto <bb 4> (<L3>); 
  # SUCC: 4 (fallthru) 
 
  # BLOCK 1 
  # PRED: 4 (true) 
<L0>:; 
  if (my_bool_2 == 0) goto <L2>; else goto <L1>; 
  # SUCC: 2 (false) 3 (true) 
 
  # BLOCK 2 
  # PRED: 1 (false) 
<L1>:; 
  my_bool_8 = 0; 
  # SUCC: 3 (fallthru) 
 
  # BLOCK 3 
  # PRED: 2 (fallthru) 1 (true) 
  # my_bool_1 = PHI <my_bool_2(1), my_bool_8(2)>; 
<L2>:; 
  i_7 = i_3 + 1; 
  # SUCC: 4 (fallthru) 
 
  # BLOCK 4 
  # PRED: 3 (fallthru) 0 (fallthru) 
  # i_3 = PHI <i_5(0), i_7(3)>; 
  # my_bool_2 = PHI <my_bool_4(0), my_bool_1(3)>; 
<L3>:; 
  if (i_3 <= 9) goto <L0>; else goto <L4>; 
  # SUCC: 5 (false) 1 (true) 
 
  # BLOCK 5 
  # PRED: 4 (false) 
<L4>:; 
  return my_bool_2; 
  # SUCC: EXIT 
 
} 
 
 
Then we go do jump threading in DOM1, and we start with: 
  Threaded jump 0 --> 4 to 1 
 
I.e. we bypass the PHI my_bool_2, then note that my_bool must 
be 0, and finally we make the function return 0, effectively 
making all other statements dead: 
 
main () 
{ 
  int i; 
  int my_bool; 
 
  # BLOCK 0 
  # PRED: ENTRY (fallthru) 
  my_bool_1 = 1; 
  i_16 = 0; 
  my_bool_17 = 1; 
  i_18 = 0; 
  my_bool_19 = 1; 
  i_20 = 0; 
  # SUCC: 1 (fallthru) 
 
  # BLOCK 1 
  # PRED: 0 (fallthru) 
<L1>:; 
  my_bool_21 = 0; 
  my_bool_22 = 0; 
  my_bool_23 = 0; 
  # SUCC: 2 (fallthru) 
 
  # BLOCK 2 
  # PRED: 2 (true) 1 (fallthru) 
  # i_2 = PHI <0(1), i_24(2)>; 
<L2>:; 
  i_24 = i_2 + 1; 
  if (i_24 <= 9) goto <L2>; else goto <L4>; 
  # SUCC: 3 (false) 2 (true) 
 
  # BLOCK 3 
  # PRED: 2 (false) 
<L4>:; 
  return 0; 
  # SUCC: EXIT 
 
} 
 
After DCE2, not a whole lot remains of the original function: 
 
main () 
{ 
  int i; 
  int my_bool; 
 
  # BLOCK 0 
  # PRED: ENTRY (fallthru) 
  # SUCC: 1 (fallthru) 
 
  # BLOCK 1 
  # PRED: 0 (fallthru) 1 (true) 
  # i_2 = PHI <0(0), i_24(1)>; 
<L2>:; 
  i_24 = i_2 + 1; 
  if (i_24 <= 9) goto <L2>; else goto <L4>; 
  # SUCC: 2 (false) 1 (true) 
 
  # BLOCK 2 
  # PRED: 1 (false) 
<L4>:; 
  return 0; 
  # SUCC: EXIT 
} 
 
So returns 0 with optimization enabled. 
 
Perhaps Jeff can look into all those dead assignments??? 
 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |law at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]