This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/56352] New: Simplify testing of related conditions in for loop


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]