This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/64622] New: convoluted loop codegen for __strcspn_c1
- From: "hubicka at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 16 Jan 2015 01:57:02 +0000
- Subject: [Bug tree-optimization/64622] New: convoluted loop codegen for __strcspn_c1
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64622
Bug ID: 64622
Summary: convoluted loop codegen for __strcspn_c1
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: hubicka at gcc dot gnu.org
Compiling
extern __inline long
__strcspn_c1 (__const char *__s, int __reject)
{
register long __result = 0;
while (__s[__result] != '\0' && __s[__result] != __reject)
++__result;
return __result;
}
With -O2 gives:
__strcspn_c1:
.LFB0:
.cfi_startproc
movsbl (%rdi), %eax
testb %al, %al
je .L4
cmpl %eax, %esi
movl $0, %eax
jne .L3
jmp .L2
.p2align 4,,10
.p2align 3
.L12:
cmpl %esi, %edx
je .L11
.L3:
addq $1, %rax
movsbl (%rdi,%rax), %edx
testb %dl, %dl
jne .L12
.L2:
rep ret
.p2align 4,,10
.p2align 3
.L11:
rep ret
.L4:
xorl %eax, %eax
ret
Whilie clang produces:
__strcspn_c1: # @__strcspn_c1
.cfi_startproc
# BB#0:
movq $-1, %rax
.align 16, 0x90
.LBB0_1: # =>This Inner Loop Header: Depth=1
movsbl 1(%rdi,%rax), %ecx
incq %rax
testl %ecx, %ecx
je .LBB0_3
# BB#2: # in Loop: Header=BB0_1 Depth=1
cmpl %esi, %ecx
jne .LBB0_1
.LBB0_3: # %.critedge
retq