This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/56352] New: Simplify testing of related conditions in for loop
- From: "josh.m.conner at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 15 Feb 2013 22:36:20 +0000
- Subject: [Bug tree-optimization/56352] New: Simplify testing of related conditions in for loop
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56352
Bug #: 56352
Summary: Simplify testing of related conditions in for loop
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: josh.m.conner@gmail.com
If we have a loop like this:
for (i = 0; i < a && i < b; i++)
{
/* Code which cannot affect i, a, or b */
}
gcc should be able to optimize this into:
tmp = MIN(a,b)
for (i = 0; i < tmp; i++)
{
/* Body */
}
But it does not. Similarly, code like:
for (i = 0; i < a; i++)
{
if (i >= b)
break;
/* Code which cannot affect i, a, or b */
}
Should be similarly optimized.