-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.
Description
This:
extern {
fn f();
}
pub unsafe fn test_loop() {
for _ in 1 ..= 7 {
f();
}
}
on 1.42:
example::test_loop:
push rbx
mov rbx, qword ptr [rip + f@GOTPCREL]
call rbx
call rbx
call rbx
call rbx
call rbx
call rbx
mov rax, rbx
pop rbx
jmp rax
on 1.43 and above:
example::test_loop:
push rbp
push r15
push r14
push rbx
push rax
mov ebx, 1
mov r14d, 7
mov r15, qword ptr [rip + f@GOTPCREL]
.LBB0_1:
lea ebp, [rbx + 1]
cmp ebx, 7
cmovge ebp, r14d
call r15
cmp ebp, 7
jg .LBB0_3
cmp ebx, 7
mov ebx, ebp
jl .LBB0_1
.LBB0_3:
add rsp, 8
pop rbx
pop r14
pop r15
pop rbp
ret
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.