[llvm-bugs] [Bug 24998] New: auto-vectorization regression in clang-3.7.0

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 30 01:31:27 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24998

            Bug ID: 24998
           Summary: auto-vectorization regression in clang-3.7.0
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: sbn at tbricks.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

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.

-- 
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/20150930/edd23634/attachment-0001.html>


More information about the llvm-bugs mailing list