[LLVMbugs] [Bug 9475] New: branch vs. indirect call

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Mar 13 01:42:49 PST 2011


           Summary: branch vs. indirect call
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu

These two lines should do the same thing:
  return i > 4 ? f() : g();
  return (i > 4 ? f : g)();
The first one produces LLVM IR that does a branch to two blocks each with a
tail call, then branches back to the join block with a phi and ret. On x86, the
final assembly has a branch (not a cmov) to place the call (not tail!) and ret
in each block.

The second one produces LLVM IR that is a single BB with the icmp+select+tail
call. The generated code is branchless and has a single tail call, but it's an
indirect function call.

I think we should fix the codegen of the former to use a tail call, then
optimize the second down to the first.

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