[LLVMbugs] [Bug 530] NEW: Loop simplify pass messes up CFG
    bugzilla-daemon at cs.uiuc.edu 
    bugzilla-daemon at cs.uiuc.edu
       
    Sun Feb 27 11:54:35 PST 2005
    
    
  
http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=530
           Summary: Loop simplify pass messes up CFG
           Product: libraries
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: jeffc at jolt-lang.org
The loop simplify pass is taking something like this:
  for ()
   X
   if ()
      Y
    else
      Z
Which looks like this:
for:
  X
  br YBB, ZBB
YBB:
  Y
  br for
ZBB:
  Z
  br for
... and transforming it.  Note that it *should* cannonicalize this loop, because
there are two backedges.  The problem is that it should generate this:
for:
  X
  br YBB, ZBB
YBB:
  Y
  br LoopEnd
ZBB:
  Z
  br LoopEnd
LoopEnd:
  br For    // single backedge
But instead it is turning it into a bastardized nested loop like this:
for2:
  br for
for:
  X
  br YBB, ZBB
YBB:
  Y
  br for   // single backedge for 'for' loop
ZBB:
  Z
  br for2  // single backedge for 'for2' loop
... which is ... *NOT GOOD*. 
A concrete example of C code that reproduces this is:
   int func(int x);
   double init_board(double a[10][10], int n)
   {
     int i;
     int j;
     double k = 0;
     for (j = 0; j < n; j++)
       for (i = 0; i < n; i++) {
         if (func(i))
           a[j][i] = 0.4;
         else
           k = a[j][i];
       }
     return k;
   }
Note the code generated for the call to func().
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
    
    
More information about the llvm-bugs
mailing list