[LLVMbugs] [Bug 17113] New: extra zeroing move operation executed
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Sep 5 14:45:51 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=17113
Bug ID: 17113
Summary: extra zeroing move operation executed
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: kkhoo at perfwizard.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
$ ./clang -v
clang version 3.4 (trunk 189776)
Target: x86_64-apple-darwin11.4.2
Thread model: posix
$ cat power_of_2.c
unsigned int power_of_two(unsigned int x) {
return x && !(x & (x - 1));
}
$ ./clang -S -O3 -fomit-frame-pointer power_of_2.c -o /dev/stdout
.section __TEXT,__text,regular,pure_instructions
.globl _power_of_two
.align 4, 0x90
_power_of_two: ## @power_of_two
.cfi_startproc
## BB#0: ## %entry
## kill: EDI<def> EDI<kill> RDI<def>
xorl %eax, %eax
testl %edi, %edi
je LBB0_2
## BB#1: ## %land.rhs
leal -1(%rdi), %eax
testl %edi, %eax
sete %al
LBB0_2: ## %land.end
movzbl %al, %eax
ret
...
I hope I'm not missing something in reading this asm...
In the case where x==0, we execute the 'test' to see if x==0 and then 'je'
(jump if equal to 0) to the 'movzb' instruction. However, we've already ensured
that %eax is zeroed out at this point via the 'xor'. Couldn't we have jumped
straight to the 'ret'?
--
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/20130905/f4c3c6af/attachment.html>
More information about the llvm-bugs
mailing list