[Bug tree-optimization/19659] New: GCC does remove an "if" statement that never triggers.
kazu at cs dot umass dot edu
gcc-bugzilla@gcc.gnu.org
Thu Jan 27 19:59:00 GMT 2005
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
More information about the Gcc-bugs
mailing list