<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Propagate constants into loads if dominated by str(n)cmp/memcmp"
href="https://bugs.llvm.org/show_bug.cgi?id=42308">42308</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Propagate constants into loads if dominated by str(n)cmp/memcmp
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>david.bolvansky@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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"</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>