<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 - Loop not vectorized with -march=haswell"
href="https://bugs.llvm.org/show_bug.cgi?id=47282">47282</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Loop not vectorized with -march=haswell
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Loop Optimizer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>david.bolvansky@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>void test1(int*__restrict n1, int*__restrict n2,
int*__restrict n3, int*__restrict n4, unsigned N)
{
for (int n = 0; n < N; ++n)
{
if (n1[n] > 0)
n2[n] = n3[n];
else
n2[n] = n4[n];
}
}
Clang:
.LBB0_7: # =>This Inner Loop Header: Depth=1
cmp dword ptr [rdi + 4*r10], 0
mov rax, rcx
cmovg rax, rdx
mov eax, dword ptr [rax + 4*r10]
mov dword ptr [rsi + 4*r10], eax
cmp dword ptr [rdi + 4*r10 + 4], 0
mov rax, rcx
cmovg rax, rdx
mov eax, dword ptr [rax + 4*r10 + 4]
mov dword ptr [rsi + 4*r10 + 4], eax
cmp dword ptr [rdi + 4*r10 + 8], 0
mov rax, rcx
cmovg rax, rdx
mov eax, dword ptr [rax + 4*r10 + 8]
mov dword ptr [rsi + 4*r10 + 8], eax
cmp dword ptr [rdi + 4*r10 + 12], 0
mov rax, rcx
cmovg rax, rdx
mov eax, dword ptr [rax + 4*r10 + 12]
mov dword ptr [rsi + 4*r10 + 12], eax
add r10, 4
cmp r9, r10
jne .LBB0_7
GCC/ICC:
.L5:
vmovdqu ymm0, YMMWORD PTR [rdi+rax]
vpcmpgtd ymm1, ymm0, ymm2
vpminsd ymm4, ymm0, ymm2
vpmaskmovd ymm3, ymm1, YMMWORD PTR [rdx+rax]
vpcmpeqd ymm0, ymm0, ymm4
vpmaskmovd ymm0, ymm0, YMMWORD PTR [rcx+rax]
vpblendvb ymm0, ymm0, ymm3, ymm1
vmovdqu YMMWORD PTR [rsi+rax], ymm0
add rax, 32
cmp rax, r9
jne .L5
mov eax, r8d
and eax, -8
mov r9d, eax
cmp r8d, eax
je .L22
vzeroupper
<a href="https://godbolt.org/z/h9hbfv">https://godbolt.org/z/h9hbfv</a></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>