[llvm-bugs] [Bug 44148] New: Missed vectorization opportunity
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Nov 26 03:51:57 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=44148
Bug ID: 44148
Summary: Missed vectorization opportunity
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at lists.llvm.org
#define N 512
int a[N], b[N];
int
foo (int aval)
{
int res = 0;
for (int i=0; i<N; i++)
{
if (a[i] != 0)
res = aval;
}
return res;
}
Clang -O3 -march=haswell: loop not vectorized [-Rpass-missed=loop-vectorize]
foo(int): # @foo(int)
xor eax, eax
mov rcx, -2048
.LBB0_1: # =>This Inner Loop Header: Depth=1
mov edx, dword ptr [rcx + a+2052]
or edx, dword ptr [rcx + a+2048]
or edx, dword ptr [rcx + a+2056]
or edx, dword ptr [rcx + a+2060]
or edx, dword ptr [rcx + a+2064]
or edx, dword ptr [rcx + a+2068]
or edx, dword ptr [rcx + a+2072]
or edx, dword ptr [rcx + a+2076]
cmovne eax, edi
add rcx, 32
jne .LBB0_1
ret
a:
.zero 2048
b:
.zero 2048
ICC -O3 -march=haswell:
foo(int):
xor eax, eax #10.11
vpxor ymm1, ymm1, ymm1 #13.17
xor edx, edx #11.3
vpcmpeqd ymm0, ymm0, ymm0 #10.11
..B1.2: # Preds ..B1.2 ..B1.1
vpcmpeqd ymm2, ymm1, YMMWORD PTR [a+rdx*4] #13.17
add rdx, 8 #11.3
vpxor ymm3, ymm2, ymm0 #10.11
vmovmskps ecx, ymm3 #10.11
or eax, ecx #10.11
cmp rdx, 512 #11.3
jb ..B1.2 # Prob 99% #11.3
test eax, eax #16.10
cmovne eax, edi #16.10
vzeroupper #16.10
ret #16.10
a:
b:
https://godbolt.org/z/AjRQNY
This loop is similar, also not vectorized:
int
foo (int aval)
{
int res = 0;
for (int i=0; i<N; i++)
{
if (a[i] != 0)
res = b[i];
}
return res;
}
https://godbolt.org/z/AU_5rf
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191126/656f74ae/attachment.html>
More information about the llvm-bugs
mailing list