public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/24028] New: CCP is broken
@ 2005-09-23  5:02 kazu at gcc dot gnu dot org
  2005-09-23  5:25 ` [Bug tree-optimization/24028] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: kazu at gcc dot gnu dot org @ 2005-09-23  5:02 UTC (permalink / raw)
  To: gcc-bugs

Consider:

int
foo (int a)
{
  int b;
  int c;

  b = 0;
  if (b)
    c = a;
  else
    c = 9;

  return c;
}

At the end of CCP, we should see "return 9;".
However, we don't.

Here is the SSA form right before CCP.

foo (a)
{
  int c;
  int b;
  int D.1612;

<bb 0>:
  b_2 = 0;
  if (b_2 != 0) goto <L0>; else goto <L1>;

<L0>:;
  c_7 = a_6;
  goto <bb 3> (<L2>);

<L1>:;
  c_5 = 9;

  # c_1 = PHI <c_7(1), c_5(2)>;
<L2>:;
  c_3 = c_1;
  return c_3;

}

Here is a part of the output from CCP.

Simulating block 3

Visiting statement:
c_3 = c_1;

Lattice value changed to VARYING.  Adding SSA edges to worklist.

Note that c_3 is considered VARYING even though it should have
a constant value of 9.

This is really strange because CCP does not visit block 1 (or <L0>).
So when evaluating the PHI node

  # c_1 = PHI <c_7(1), c_5(2)>;

c_1 should get 9, and CCP does know that c_5 is equal to 9.

-- 
           Summary: CCP is broken
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

end of thread, other threads:[~2008-06-01  9:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-24028-5009@http.gcc.gnu.org/bugzilla/>
2006-02-05 21:26 ` [Bug tree-optimization/24028] CCP is broken pinskia at gcc dot gnu dot org
2006-02-05 21:43 ` kazu at gcc dot gnu dot org
2008-06-01  9:42 ` steven at gcc dot gnu dot org
2005-09-23  5:02 [Bug tree-optimization/24028] New: " kazu at gcc dot gnu dot org
2005-09-23  5:25 ` [Bug tree-optimization/24028] " pinskia at gcc dot gnu dot org
2005-09-23  5:30 ` kazu at gcc dot gnu dot org
2005-09-23 12:30 ` dnovillo at redhat dot com
2005-09-24  4:29 ` kazu at gcc dot gnu dot org
2005-09-25  2:57 ` kazu 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).