------- Comment #17 from manu at gcc dot gnu dot org  2009-02-07 15:35 -------
Without optimization we build the following:

foo ()
{
  intD.0 iD.1591;

  # BLOCK 2
  # PRED: ENTRY (fallthru)
  [pr22456.c : 4] goto <bb 4>;
  # SUCC: 4 (fallthru)

  # BLOCK 3
  # PRED: 4 (true)
  [pr22456.c : 4] iD.1591_3 = iD.1591_1 + 1;
  # SUCC: 4 (fallthru)

  # BLOCK 4
  # PRED: 2 (fallthru) 3 (fallthru)
  # iD.1591_1 = PHI <iD.1591_2(D)(2), iD.1591_3(3)>
  [pr22456.c : 4] if (iD.1591_1 != 0)
    goto <bb 3>;
  else
    goto <bb 5>;
  # SUCC: 3 (true) 5 (false)

  # BLOCK 5
  # PRED: 4 (false)
  [pr22456.c : 5] return;
  # SUCC: EXIT

}

Because of the way the loop is represented, we generate a PHI node for the
condition instead of a direct use. Since we do not warn about PHI nodes without
optimization, then there is no warning.

With optimization the loop is completely removed since it doesn't do anything.
Hence, there is no warning. I wasn't able to construct a testcase where the
loop does anything useful (or the value of "i" is used after the loop) and we
do not warn.

This doesn't have anything to do with CCP and it is not a duplicate of bug
18501.

Closed as INVALID. If anyone comes up with a testcase for this where the loop
is not empty, open a new PR and add me to the CC.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|18501                       |
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


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

Reply via email to