[llvm-bugs] [Bug 52355] New: Missed DCE/loop deletion
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 29 12:17:56 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=52355
Bug ID: 52355
Summary: Missed DCE/loop deletion
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at lists.llvm.org
inline unsigned int
stringLen(const short* const src)
{
if (src == 0 || *src == 0) {
return 0;
} else {
const short* pszTmp = src + 1;
while (*pszTmp)
++pszTmp;
return (unsigned int)(pszTmp - src);
}
}
extern void bar();
void foo(const short* const str) {
unsigned int len = stringLen(str);
if (!len) {
bar();
}
}
LLVM:
foo(short const*): # @foo(short const*)
test rdi, rdi
je .LBB0_6
cmp word ptr [rdi], 0
je .LBB0_6
xor eax, eax
.LBB0_3: # =>This Inner Loop Header: Depth=1
cmp word ptr [rdi + rax + 2], 0
lea rax, [rax + 2]
jne .LBB0_3
shr rax
test eax, eax
je .LBB0_6
ret
.LBB0_6:
jmp bar() # TAILCALL
ICC is smarter here:
foo(short const*):
test rdi, rdi #4.16
je ..B1.4 # Prob 5% #4.16
movsx eax, WORD PTR [rdi] #4.22
test eax, eax #4.29
jne ..B1.5 # Prob 72% #4.29
..B1.4: # Preds ..B1.2 ..B1.1
jmp bar() #21.9
..B1.5: # Preds ..B1.2
ret
https://godbolt.org/z/erWa6efKa
#23.1
--
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/20211029/1d026b3c/attachment.html>
More information about the llvm-bugs
mailing list