[llvm-bugs] [Bug 34911] New: Redundant comparisons are not eliminated
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 10 19:42:04 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34911
Bug ID: 34911
Summary: Redundant comparisons are not eliminated
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: jmuizelaar at mozilla.com
CC: llvm-bugs at lists.llvm.org
#include <stdlib.h>
int f(int x) {
if (x < 4)
exit(1);
if (x < 8)
exit(1);
if (x < 12)
exit(1);
if (x < 16)
exit(1);
return x + 5;
}
compiles to:
f(int): # @f(int)
pushq %rax
cmpl $3, %edi
jle .LBB0_5
cmpl $7, %edi
jle .LBB0_5
cmpl $11, %edi
jle .LBB0_5
cmpl $15, %edi
jle .LBB0_5
addl $5, %edi
movl %edi, %eax
popq %rcx
retq
.LBB0_5:
movl $1, %edi
callq exit
compared to gcc's
f(int):
cmpl $15, %edi
jle .L7
leal 5(%rdi), %eax
ret
.L7:
subq $8, %rsp
movl $1, %edi
call exit
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171011/0ed52bf8/attachment.html>
More information about the llvm-bugs
mailing list