http://llvm.org/bugs/show_bug.cgi?id=9408
Summary: Missed optimization: branch to duplicate code
Product: libraries
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: Transformation Utilities
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Here's an example of a missed optimization opportunity from
http://blog.reverberate.org/2011/03/03/gcc-the-impressive-and-the-disappointing/
This code:
typedef union {
void (*f1)(int);
void (*f2)(long);
} funcs;
void foo(funcs f, int which) {
int a = 5;
if (which) {
f.f1(a);
} else {
f.f2(a);
}
}
generates the following code which has a branch to duplicate code.
foo: # @foo
# BB#0: # %entry
pushq %rbp
movq %rsp, %rbp
testl %esi, %esi
movq %rdi, %rax
je .LBB0_2
# BB#1: # %if.then
movl $5, %edi
callq *%rax
popq %rbp
ret
.LBB0_2: # %if.else
movl $5, %edi
callq *%rax
popq %rbp
ret
--
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