<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 - missed optimization in pointer arithmetic"
href="https://bugs.llvm.org/show_bug.cgi?id=47690">47690</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>missed optimization in pointer arithmetic
</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>All
</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>ian@ianhenderson.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>godbolt.org link: <a href="https://godbolt.org/z/s3ojvE">https://godbolt.org/z/s3ojvE</a>
the following two functions both compute x - a, but the second one isn't being
optimized properly.
functions:
unsigned a, *b;
unsigned f0(unsigned x) {
return b + x - b - a;
}
unsigned f1(unsigned x) {
return b + x - a - b;
}
compiled result at -Os:
f0: # @f0
mov eax, edi
sub eax, dword ptr [rip + a]
ret
f1: # @f1
mov rcx, qword ptr [rip + b]
mov eax, edi
xor edx, edx
sub edx, dword ptr [rip + a]
lea rax, [rcx + 4*rax]
lea rax, [rax + 4*rdx]
sub rax, rcx
shr rax, 2
ret
b:
.quad 0
a:
.long 0 # 0x0
according to the versions on godbolt.org, this regressed between clang 3.6 and
3.7.</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>