[LLVMbugs] [Bug 6788] New: Missing tail-call optimization

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 5 14:32:13 PDT 2010


           Summary: Missing tail-call optimization
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: ARM
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: john at bass-software.com
                CC: llvmbugs at cs.uiuc.edu

Created an attachment (id=4641)
 --> (http://llvm.org/bugs/attachment.cgi?id=4641)
Code piece resulting in missing tail-optimization

Code piece:

target datalayout =
target triple = "armv7-unknown-eabi"

define arm_aapcscc i32 @test2(i32 %low, i32 %high) nounwind readnone {
  %conv = zext i32 %high to i64                   ; <i64> [#uses=1]
  %shl = shl i64 %conv, 32                        ; <i64> [#uses=1]
  %conv2 = zext i32 %low to i64                   ; <i64> [#uses=1]
  %add = or i64 %shl, %conv2                      ; <i64> [#uses=1]
  %div = udiv i64 %add, 3                         ; <i64> [#uses=1]
  %conv4 = trunc i64 %div to i32                  ; <i32> [#uses=1]
  ret i32 %conv4

gets compiled as (see test-indirect.ll attachment):

    stmdb    sp!, {r11, lr}
    mov    r2, #3
    mov    r3, #0
    bl    __udivdi3
    ldmia    sp!, {r11, pc}

Can't this become:

    mov    r2, #3
    mov    r3, #0
    b    __udivdi3

Aside: in case it is important, the .ll code piece came from compiling using
clang/llvm-gcc (tried both):

#include <stdint.h>

test2 (uint32_t low, uint32_t high)
  uint64_t sum = ((uint64_t)high << 32) + (uint64_t)low;
  return sum / 3ULL;

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