public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/19659] New: GCC does remove an "if" statement that never triggers.
@ 2005-01-27 19:59 kazu at cs dot umass dot edu
  2005-01-27 20:24 ` [Bug tree-optimization/19659] GCC does not " steven at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: kazu at cs dot umass dot edu @ 2005-01-27 19:59 UTC (permalink / raw)
  To: gcc-bugs

extern void abort (void) __attribute__ ((__noreturn__));

/* Count up to *LENGTHP and then return 0.  */

int
foo (unsigned *lengthp)
{
  unsigned index;

  for (index = 0; index != *lengthp; index++)
    {
      const unsigned *lengthp2 = lengthp;

      /* Note that this condition is never true.  */
      if (index >= *lengthp2)
	abort ();
    }

  return 0;
}

GCC does not remove the "if" statement even though it never triggers.

Interestingly, if you remove "const" from the testcase above, GCC does
remove the "if" statement.

If you feed the testcase with "const" into GCC, CSE removes it.
Hey, but isn't this a machine-independent optimization?

-- 
           Summary: GCC does remove an "if" statement that never triggers.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization, TREE
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


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

end of thread, other threads:[~2005-06-04 17:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-27 19:59 [Bug tree-optimization/19659] New: GCC does remove an "if" statement that never triggers kazu at cs dot umass dot edu
2005-01-27 20:24 ` [Bug tree-optimization/19659] GCC does not " steven at gcc dot gnu dot org
2005-01-27 20:34 ` pinskia at gcc dot gnu dot org
2005-01-27 21:26 ` steven at gcc dot gnu dot org
2005-02-17 14:33 ` pinskia at gcc dot gnu dot org
2005-02-19  4:02 ` dnovillo at gcc dot gnu dot org
2005-02-19  5:45 ` pinskia at gcc dot gnu dot org
2005-03-16 12:32 ` steven at gcc dot gnu dot org
2005-03-23 19:59 ` pinskia at gcc dot gnu dot org
2005-04-13 18:11 ` pinskia at gcc dot gnu dot org
2005-06-04 17:00 ` dnovillo 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).