[LLVMbugs] [Bug 10377] New: Missed optimizations with indirectbr terminators

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jul 15 23:37:14 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10377

           Summary: Missed optimizations with indirectbr terminators
           Product: new-bugs
           Version: 2.9
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: llvm-bugzilla at cafxx.strayorange.com
                CC: llvmbugs at cs.uiuc.edu


Consider this IR fragment produced by opt -O3:

> %7:
> %8 = phi i8* [ blockaddress(@0, %19), %19 ], [ %12, %11 ]
> %9 = phi i32 [ %20, %19 ], [ 0, %11 ]
> indirectbr i8* %8, [label %4, label %19]
>
> %19:
> %20 = add nsw i32 %9, 1
> %21 = icmp eq i32 %9, 9999
> br i1 %21, label %16, label %7

the br in %19 should be optimized to branch directly to itself rather than
going back to %7 (note that the arg %8 to the indirectbr will always be the
address of %19 when coming from %19). While this might or might not be so big
of a problem per-se, notice how %19 is a loop body that simply adds 1 to the
same variable at each iteration. Because the br is still pointing to %7 instead
of %18, other passes are not able to recognize that the loop has a constant
iteration count and could therefore be replaced entirely by a 

> %20 = add nsw i32 %9, 10000

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list