public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/34244]  New: [4.3 Regression] VRP/SCEV miscompiles Firefox
@ 2007-11-27 11:12 rguenth at gcc dot gnu dot org
  2007-11-27 11:30 ` [Bug tree-optimization/34244] " rguenth at gcc dot gnu dot org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-11-27 11:12 UTC (permalink / raw)
  To: gcc-bugs

int* GetParent(void);
int* FindCommonAncestor(int *aNode1, int *aNode2)
{
  if (aNode1 && aNode2) {
    int offset = 0; 
    int *anc1 = aNode1;
    for (;;) {
      ++offset;
      int * parent = GetParent();
      if (!parent)
        break;
      anc1 = parent;
    }
    int *anc2 = aNode2;
    for (;;) { 
      --offset;
      int * parent = GetParent();
      if (!parent)
        break;
      anc2 = parent;
    }
    if (anc1 == anc2) {
      anc1 = aNode1;
      anc2 = aNode2;
      while (offset > 0) {
        anc1 = GetParent();
        --offset;
      }
      while (offset < 0) {
        anc2 = GetParent();
        ++offset;
      }
      while (anc1 != anc2) {
        anc1 = GetParent();
        anc2 = GetParent();
      }
      return anc1;
    }
  }
  return 0;
}

Folding predicate offset_5 < 0 to 0
Folded statement: if (offset_5 < 0)
            into: if (0)

that is, the second last loop is never executed according to VRP/SCEV because
the exit value of the third last loop

<bb 26>:
  offset_48 = ASSERT_EXPR <offset_4, offset_4 <= 0>;

is adjusted to [0, 0] by SCEV:

Visiting statement:
offset_48 = ASSERT_EXPR <offset_4, offset_4 <= 0>;

(analyze_scalar_evolution
  (loop_nb = 0)
  (scalar = offset_48)
(get_scalar_evolution
  (scalar = offset_48)
  (scalar_evolution = ))
(analyze_scalar_evolution
  (loop_nb = 0)
  (scalar = offset_4)
(get_scalar_evolution
  (scalar = offset_4)
  (scalar_evolution = ))
(analyze_initial_condition
  (loop_phi_node =
offset_4 = PHI <offset_37(10), offset_32(9)>)
  (init_cond = offset_37))
(analyze_evolution_in_loop
  (loop_phi_node = offset_4 = PHI <offset_37(10), offset_32(9)>)
(add_to_evolution
  (loop_nb = 3)
  (chrec_before = offset_37)
  (to_add = -1)
  (res = {offset_37, +, -1}_3))
  (evolution_function = {offset_37, +, -1}_3))
(set_scalar_evolution
  (scalar = offset_4)
  (scalar_evolution = {offset_37, +, -1}_3))
(number_of_iterations_in_loop
(analyze_scalar_evolution
  (loop_nb = 3)
  (scalar = offset_4)
(get_scalar_evolution
  (scalar = offset_4)
  (scalar_evolution = {offset_37, +, -1}_3))
(set_scalar_evolution
  (scalar = offset_4)
  (scalar_evolution = {offset_37, +, -1}_3))
)
(analyze_scalar_evolution
  (loop_nb = 3)
  (scalar = 0)
(get_scalar_evolution
  (scalar = 0)
  (scalar_evolution = 0))
)
Analyzing # of iterations of loop 3
  exit condition 0 < [offset_46, + , -1](no_overflow)
  bounds on difference of bases: -2147483648 ... 2147483647
  result:
    # of iterations (unsigned int) offset_46, bounded by 2147483647
  (set_nb_iterations_in_loop = (unsigned int) offset_46))
(chrec_apply 
  (varying_loop = 3
) 
  (chrec = {offset_37, +, -1}_3)
  (x = offset_46)
  (res = offset_37 - offset_46))
(analyze_scalar_evolution
  (loop_nb = 0)
  (scalar = offset_37)
(get_scalar_evolution 
  (scalar = offset_37)
  (scalar_evolution = ))
(analyze_scalar_evolution
  (loop_nb = 0)
  (scalar = offset_46)
(get_scalar_evolution 
  (scalar = offset_46)
  (scalar_evolution = ))
(analyze_scalar_evolution
  (loop_nb = 0)
  (scalar = offset_24)
(get_scalar_evolution 
  (scalar = offset_24)
  (scalar_evolution = {offset_40 + -1, +, -1}_2))
(number_of_iterations_in_loop
(analyze_scalar_evolution
  (loop_nb = 2)
  (scalar = parent_25)
(get_scalar_evolution 
  (scalar = parent_25)
  (scalar_evolution = parent_25))
(set_scalar_evolution 
  (scalar = parent_25)
  (scalar_evolution = parent_25))
)
(analyze_scalar_evolution
  (loop_nb = 2)
  (scalar = parent_25)
(get_scalar_evolution 
  (scalar = parent_25)
  (scalar_evolution = parent_25))
(set_scalar_evolution 
  (scalar = parent_25)
  (scalar_evolution = parent_25))
) 
  (set_nb_iterations_in_loop = scev_not_known))
)
(set_scalar_evolution 
  (scalar = offset_46)
  (scalar_evolution = offset_24))
)
(set_scalar_evolution 
  (scalar = offset_37)
  (scalar_evolution = offset_24))
)
(analyze_scalar_evolution
  (loop_nb = 0)
  (scalar = offset_46)
(get_scalar_evolution
  (scalar = offset_46)
  (scalar_evolution = offset_24))
(set_scalar_evolution
  (scalar = offset_46)
  (scalar_evolution = offset_24))
)
)
(set_scalar_evolution
  (scalar = offset_48)
  (scalar_evolution = 0))
)
(instantiate_parameters
  (loop_nb = 0)
  (chrec = 0)
  (res = 0))
Found new range for offset_48: [0, 0]

where the particular error looks like this:

Analyzing # of iterations of loop 3
  exit condition 0 < [offset_46, + , -1](no_overflow)
  bounds on difference of bases: -2147483648 ... 2147483647
  result:
    # of iterations (unsigned int) offset_46, bounded by 2147483647
  (set_nb_iterations_in_loop = (unsigned int) offset_46))

as it may be zero, in case offset_46 is <= 0.

Sebastian, Zdenek - any idea what goes wrong here?


-- 
           Summary: [4.3 Regression] VRP/SCEV miscompiles Firefox
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2008-06-06 20:08 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-27 11:12 [Bug tree-optimization/34244] New: [4.3 Regression] VRP/SCEV miscompiles Firefox rguenth at gcc dot gnu dot org
2007-11-27 11:30 ` [Bug tree-optimization/34244] " rguenth at gcc dot gnu dot org
2007-11-27 12:04 ` pinskia at gcc dot gnu dot org
2007-11-27 13:57 ` rakdver at gcc dot gnu dot org
2007-11-27 14:04 ` rguenther at suse dot de
2007-11-27 16:48 ` rakdver at gcc dot gnu dot org
2007-11-27 17:00 ` rakdver at gcc dot gnu dot org
2007-11-27 22:21 ` mmitchel at gcc dot gnu dot org
2007-11-28 15:47 ` rguenth at gcc dot gnu dot org
2007-11-28 16:05 ` rakdver at kam dot mff dot cuni dot cz
2007-11-28 16:13 ` rguenther at suse dot de
2007-11-29  4:29 ` rakdver at gcc dot gnu dot org
2007-11-30  0:32 ` rakdver at gcc dot gnu dot org
2007-11-30  7:20 ` jakub at gcc dot gnu dot org
2007-11-30  8:56 ` hjl at lucon dot org
2007-11-30 13:24 ` jakub at gcc dot gnu dot org
2008-05-31 13:02 ` rguenth at gcc dot gnu dot org
2008-06-06 20:08 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).