<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - pointer arithmetic simplification"
href="http://llvm.org/bugs/show_bug.cgi?id=17616">17616</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>pointer arithmetic simplification
</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>normal
</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>marc.glisse@normalesup.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>int* f(int*b,int*e){
return b+(e-b);
}
generates this code on x86_64:
subq %rdi, %rsi
andq $-4, %rsi
addq %rdi, %rsi
movq %rsi, %rax
or in llvm terms:
%sub.ptr.lhs.cast = ptrtoint i32* %e to i64
%sub.ptr.rhs.cast = ptrtoint i32* %b to i64
%sub.ptr.sub = sub i64 %sub.ptr.lhs.cast, %sub.ptr.rhs.cast
%sub.ptr.div = ashr exact i64 %sub.ptr.sub, 2
%add.ptr = getelementptr inbounds i32* %b, i64 %sub.ptr.div
ret i32* %add.ptr
I'm sure you can guess what optimization I'd like to see...
Note that this happens in real code, for instance as a way to cast away
constness if e was const int*.</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>