<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 - [x86] large constant offsets used for memory accesses in loop"
href="https://bugs.llvm.org/show_bug.cgi?id=35681">35681</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[x86] large constant offsets used for memory accesses in loop
</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>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>spatel+llvm@rotateright.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Forking this off from <a class="bz_bug_link
bz_status_NEW "
title="NEW - Code pessimization when using typedef-aligned pointers"
href="show_bug.cgi?id=28343">bug 28343</a>:
$ cat badmax.c
void maxArray(double* __restrict x, double* __restrict y) {
for (int i = 0; i < 65536; i++) x[i] = ((y[i] > x[i]) ? y[i] : x[i]);
}
Or as IR compiled as:
$ ./clang badmax.c -S -o - -O2 -fno-unroll-loops -emit-llvm
define void @maxArray(double* noalias nocapture %x, double* noalias nocapture
readonly %y) {
entry:
br label %vector.body
vector.body:
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
%0 = getelementptr inbounds double, double* %y, i64 %index
%1 = bitcast double* %0 to <2 x double>*
%wide.load = load <2 x double>, <2 x double>* %1, align 8
%2 = getelementptr inbounds double, double* %x, i64 %index
%3 = bitcast double* %2 to <2 x double>*
%wide.load21 = load <2 x double>, <2 x double>* %3, align 8
%4 = fcmp ogt <2 x double> %wide.load, %wide.load21
%5 = select <2 x i1> %4, <2 x double> %wide.load, <2 x double> %wide.load21
%6 = bitcast double* %2 to <2 x double>*
store <2 x double> %5, <2 x double>* %6, align 8
%index.next = add i64 %index, 2
%7 = icmp eq i64 %index.next, 65536
br i1 %7, label %for.cond.cleanup, label %vector.body
for.cond.cleanup:
ret void
}
-----------------------------------------------------------------------------
$ ./llc -o - badmax.ll -mtriple=x86_64
movq $-524288, %rax # imm = 0xFFF80000
.p2align 4, 0x90
.LBB0_1:
movupd 524288(%rsi,%rax), %xmm0
movupd 524288(%rdi,%rax), %xmm1
maxpd %xmm1, %xmm0
movupd %xmm0, 524288(%rdi,%rax)
addq $16, %rax
jne .LBB0_1
retq</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>