<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 --- - clang: Alignment causing wrong results"
href="http://llvm.org/bugs/show_bug.cgi?id=17770">17770</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang: Alignment causing wrong results
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.3
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ted@krovetz.net
</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>The following code, compiled as "clang -O0 -mfpu=neon tst.c", causes 0 to be
output when run on a Cortex-A9 with current Arch Linux. Under gcc it outputs 11
(which is correct). When I add "__attribute__ ((aligned(16)))" in front of any
of the arrays declared in main(), clang code also returns 11.
Since all pointers are element aligned, I didn't expect this behavior.
#include <arm_neon.h>
#include <stdio.h>
void nh(unsigned long long *hp, unsigned *kp, unsigned *mp) {
uint32x4_t k = *(uint32x4_t *)kp;
uint32x4_t m = *(uint32x4_t *)mp;
uint64x2_t a = vmovq_n_u64(0);
a = vmlal_u32(a, vget_high_u32(k + m), vget_low_u32(k + m));
hp[0] = (unsigned long long)(vget_high_u64(a) + vget_low_u64(a));
}
int main() {
unsigned k[4] = {0,0,0,0};
unsigned m[4] = {1,2,3,4};
unsigned long long h[2] = {0};
nh(h,k,m);
printf("%llu\n",h[0]);
return 0;
}</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>