http://llvm.org/bugs/show_bug.cgi?id=3253
Summary: missed optimization: shl + test -> bt
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P2
Component: Common Code Generator Code
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Consider this code:
int foo(char *c)
{
return strcspn(c, ":\r\n");
}
llvm-gcc translates this into this (which is better than gcc, which does 3
cmpb!):
.text
.align 16
.globl foo
.type foo,@function
foo:
xorl %eax, %eax
jmp .LBB1_2 # bb24
.LBB1_1: # bb23
incq %rax
.LBB1_2: # bb24
movb (%rdi,%rax), %cl
movl $1, %edx
shlq %cl, %rdx
cmpb $58, %cl
ja .LBB1_1 # bb23
.LBB1_3: # bb24
movabsq $288230376151720961, %rcx
testq %rcx, %rdx
je .LBB1_1 # bb23
.LBB1_4: # bb35
ret
.size foo, .-foo
Tron on #llvm suggested that it could be improved even further:
* movl $1, %rdx; shl %cl, %rdx; test %ecx, %edx == bt
* loading the huge constant (the instruction is 10 bytes long!) should be
moved out of the loop
--
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