<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 --- - auto-vectorization regression in clang-3.7.0"
href="https://llvm.org/bugs/show_bug.cgi?id=24998">24998</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>auto-vectorization regression in clang-3.7.0
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>sbn@tbricks.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Hi!
We noticed performance regression in our application after switching to clang
3.7.0 from 3.6.1
We have a feeling that partially it can be attributed to auto-vectorization
failure for some loops that were vectorized by 3.6.1
Here is small test:
$ cat -n a.cpp
1 #define N 200
2
3 template<typename T>
4 T const& max(T const& a, T const& b) { return (a < b ? b : a); }
5
6 void sink(double*, int);
7
8 void foo(double pv, double X)
9 {
10 double a[N], b[N], c[N];
11
12 for (int i = 0; i < N; ++i) {
13 a[i] = max(pv * b[i], X - c[i]); // 3.6.1 can vectorizes,
3.7.0 -- can't
14 }
15
16 sink(a, N);
17 }
$ /opt/llvm-3.6.1/bin/clang++ -stdlib=libc++ -v -O3 -Rpass=loop-vectorize
-Rpass-missed=loop-vectorize -Rpass-analysis=loop-vectorize -c a.cpp
clang version 3.6.1 (tags/RELEASE_361/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.7
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.7
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
"/opt/llvm-3.6.1/bin/clang-3.6" -cc1 -triple x86_64-unknown-linux-gnu
-emit-obj -disable-free -disable-llvm-verifier -main-file-name a.cpp
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64
-momit-leaf-frame-pointer -v -dwarf-column-info -coverage-file
/nfshome/sbn/my-work/tst/vectorization/a.cpp -resource-dir
/opt/llvm-3.6.1/bin/../lib64/clang/3.6.1 -internal-isystem
/opt/llvm-3.6.1/bin/../include/c++/v1 -internal-isystem /usr/local/include
-internal-isystem /opt/llvm-3.6.1/bin/../lib64/clang/3.6.1/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O3
-Rpass=loop-vectorize -Rpass-missed=loop-vectorize
-Rpass-analysis=loop-vectorize -fdeprecated-macro -fdebug-compilation-dir
/nfshome/sbn/my-work/tst/vectorization -ferror-limit 19 -fmessage-length 237
-mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-o a.o -x c++ a.cpp
clang -cc1 version 3.6.1 based upon LLVM 3.6.1 default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/llvm-3.6.1/bin/../include/c++/v1
/usr/local/include
/opt/llvm-3.6.1/bin/../lib64/clang/3.6.1/include
/usr/include
End of search list.
a.cpp:12:5: remark: vectorized loop (vectorization factor: 2, unrolling
interleave factor: 2) [-Rpass=loop-vectorize]
for (int i = 0; i < N; ++i) {
^
$ /opt/llvm-3.7.0/bin/clang++ -stdlib=libc++ -v -O3 -Rpass=loop-vectorize
-Rpass-missed=loop-vectorize -Rpass-analysis=loop-vectorize -c a.cpp
clang version 3.7.0 (tags/RELEASE_370/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.7
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.7
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
"/opt/llvm-3.7.0/bin/clang-3.7" -cc1 -triple x86_64-unknown-linux-gnu
-emit-obj -disable-free -disable-llvm-verifier -main-file-name a.cpp
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64
-momit-leaf-frame-pointer -v -dwarf-column-info -coverage-file
/nfshome/sbn/my-work/tst/vectorization/a.cpp -resource-dir
/opt/llvm-3.7.0/bin/../lib64/clang/3.7.0 -internal-isystem /usr/include/c++/v1
-internal-isystem /usr/local/include -internal-isystem
/opt/llvm-3.7.0/bin/../lib64/clang/3.7.0/include -internal-externc-isystem
/include -internal-externc-isystem /usr/include -O3 -Rpass=loop-vectorize
-Rpass-missed=loop-vectorize -Rpass-analysis=loop-vectorize -fdeprecated-macro
-fdebug-compilation-dir /nfshome/sbn/my-work/tst/vectorization -ferror-limit 19
-fmessage-length 237 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops
-vectorize-slp -o a.o -x c++ a.cpp
clang -cc1 version 3.7.0 based upon LLVM 3.7.0 default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/v1
/usr/local/include
/opt/llvm-3.7.0/bin/../lib64/clang/3.7.0/include
/usr/include
End of search list.
a.cpp:12:5: remark: loop not vectorized: cannot identify array bounds
[-Rpass-analysis=loop-vectorize]
for (int i = 0; i < N; ++i) {
^
a.cpp:12:5: remark: loop not vectorized: use -Rpass-analysis=loop-vectorize for
more info [-Rpass-missed=loop-vectorize]
I also checked 'trunk' and it behaves as 3.7.0
Note also the commented line in test -- it can be successfully vectorized by
all 3.6.1, 3.7.0 and trunk.
So it looks like this 'max()' call (it's std::max() in real code) somehow
confuses 3.7.0, but I don't understand how it can affect array bounds checking.
BTW if I change max() function to return value instead of const ref
vectorization succeeded.</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>