[llvm-bugs] [Bug 42308] New: Propagate constants into loads if dominated by str(n)cmp/memcmp
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jun 18 09:53:23 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42308
Bug ID: 42308
Summary: Propagate constants into loads if dominated by
str(n)cmp/memcmp
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at lists.llvm.org
Motivation:
char f(char* s) {
if (strcmp(s, "test") == 0) return s[0];
return '-';
}
--->
char f2(char* s) {
if (strcmp(s, "test") == 0) return 't';
return '-';
}
f(char*): # @f(char*)
push rbx
mov rbx, rdi
mov esi, offset .L.str
call strcmp
mov ecx, eax
mov al, 45
test ecx, ecx
je .LBB0_1
pop rbx
ret
.LBB0_1:
mov al, byte ptr [rbx]
pop rbx
ret
f2(char*): # @f2(char*)
push rax
mov esi, offset .L.str
call strcmp
test eax, eax
mov ecx, 116
mov eax, 45
cmove eax, ecx
pop rcx
ret
.L.str:
.asciz "test"
--
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/20190618/89dd99bb/attachment.html>
More information about the llvm-bugs
mailing list