http://llvm.org/bugs/show_bug.cgi?id=9757
Summary: Suboptimal register allocation/scheduling on simple
function
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: code-quality
Severity: normal
Priority: P
Component: Register Allocator
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
If a compile the following testcase on arm thumb2:
--------------------------------------------------------------
$cat test.c
void bar(void*,unsigned long,unsigned long);
void foo(unsigned long a, unsigned long b)
{
bar(&b, a, 4);
}
$clang -cc1 -triple=thumbv7-u-u -Os -o - test.c -S -mrelocation-model static
[...]
foo:
str lr, [sp, #-4]!
sub sp, #4
mov r3, r0
str r1, [sp]
mov r0, sp
movs r2, #4
mov r1, r3
bl bar
add sp, #4
ldr lr, [sp], #4
bx lr
[...]
-----------------------------------------------
The code can be smaller with the following instruction sequence:
(merge the instructions mov r3,r0 and mov r1,r3 into mov r1,r0)
foo:
str lr, [sp, #-4]!
sub sp, #4
str r1, [sp]
mov r3, r1
mov r0, sp
movs r2, #4
bl bar
add sp, #4
ldr lr, [sp], #4
bx lr
Am I missing something ?
I am not an expert with register allocation and scheduling,
=> What prevents llvm to generate this better code ?
I tried to disable stall and hazard scheduling using '-disable-sched-hazard'
and '-disable-sched-stall', but it doesn't change anything.
--
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs