[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
http://llvm.org/bugs/show_bug.cgi?id=6788
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:
--8<--
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n32"
target triple = "armv7-unknown-eabi"
define arm_aapcscc i32 @test2(i32 %low, i32 %high) nounwind readnone {
entry:
%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
}
--8<--
gets compiled as (see test-indirect.ll attachment):
--8<--
test2:
stmdb sp!, {r11, lr}
mov r2, #3
mov r3, #0
bl __udivdi3
ldmia sp!, {r11, pc}
--8<--
Can't this become:
--8<--
test2:
mov r2, #3
mov r3, #0
b __udivdi3
--8<--
Aside: in case it is important, the .ll code piece came from compiling using
clang/llvm-gcc (tried both):
--8<--
#include <stdint.h>
uint32_t
test2 (uint32_t low, uint32_t high)
{
uint64_t sum = ((uint64_t)high << 32) + (uint64_t)low;
return sum / 3ULL;
}
--8<--
--
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