This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/52070] New: missing integer comparison optimization
- From: "drepper.fsp at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 31 Jan 2012 19:39:49 +0000
- Subject: [Bug tree-optimization/52070] New: missing integer comparison optimization
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52070
Bug #: 52070
Summary: missing integer comparison optimization
Classification: Unclassified
Product: gcc
Version: 4.6.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: drepper.fsp@gmail.com
Compile this code with gcc 4.6.2:
#include <stddef.h>
size_t b;
int f(size_t a)
{
return b == 0 || a < b;
}
For x86-64 I see this result:
f: movq b(%rip), %rdx
movl $1, %eax
testq %rdx, %rdx
je .L2
xorl %eax, %eax
cmpq %rdi, %rdx
seta %al
.L2: rep ret
This can be more done without a conditional jump:
f: movq b(%rip), %rdx
xorl %eax, %eax
subq $1, %rdx
cmpq %rdi, %rdx
setae %al
rep ret
Unless the b==0 test is marked as likely I'd say this code is performing better
on all architectures.