<html>
<head>
<base href="https://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 --- - Alias analysis fails to recognize non-zero variable offset"
href="https://llvm.org/bugs/show_bug.cgi?id=23067">23067</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Alias analysis fails to recognize non-zero variable offset
</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>Global Analyses
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>james.molloy@arm.com
</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>In the following code, &a[i] cannot alias &a[i+m], as m is known to be nonzero.
However, *x is reloaded across the "*w >>= 1" statement.
void test(int n, int m, int * restrict a)
{
for (int j = 0; j < m; ++j) {
for (int i = j; i < n; ++i) {
int *x = &a[i];
int *w = &a[i+m];
*x >>= 1;
*w >>= 1;
*x += 2;
}
}
}
... Produces:
for.body3: ; preds =
%for.body3.preheader, %for.body3
%indvars.iv23 = phi i64 [ %indvars.iv.next24, %for.body3 ], [ %indvars.iv,
%for.body3.preheader ]
%arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv23
%1 = add nsw i64 %indvars.iv23, %0
%arrayidx5 = getelementptr inbounds i32, i32* %a, i64 %1
%2 = load i32, i32* %arrayidx, align 4, !tbaa !1
%shr = ashr i32 %2, 1
store i32 %shr, i32* %arrayidx, align 4, !tbaa !1 *** POINTLESS
STORE
%3 = load i32, i32* %arrayidx5, align 4, !tbaa !1
%shr6 = ashr i32 %3, 1
store i32 %shr6, i32* %arrayidx5, align 4, !tbaa !1
%4 = load i32, i32* %arrayidx, align 4, !tbaa !1 *** POINTLESS
RELOAD
%add7 = add nsw i32 %4, 2
store i32 %add7, i32* %arrayidx, align 4, !tbaa !1
%indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1
%lftr.wideiv = trunc i64 %indvars.iv.next24 to i32
%exitcond = icmp eq i32 %lftr.wideiv, %n
br i1 %exitcond, label %for.inc8.loopexit, label %for.body3</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>