http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46265
Summary: Missing ifcvt
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: [email protected]
ReportedBy: [email protected]
Compile the following code with -O2
int *gp;
int g, g2;
int foo(int p)
{
int t = 0;
if (p)
t = *gp + 1;
return (*gp + t);
}
Trunk gcc produces:
movq gp(%rip), %rax
xorl %edx, %edx
movl (%rax), %eax
testl %edi, %edi
je .L3
leal 1(%rax), %edx
.L3:
addl %edx, %eax
ret
llvm (with clang) produces:
movq gp(%rip), %rax
movl (%rax), %ecx
leal 1(%rcx), %edx
testl %edi, %edi
movl $0, %eax
cmovnel %edx, %eax
addl %ecx, %eax
ret
Gcc's ifcvt seems weak. If changing t=*gp + 1 to t = g then the assignment can
be ifcvted by gcc.
David