[llvm-bugs] [Bug 32391] New: Optimization flag -O2 gives wrong results for SSE2 and AVX intrinsics

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 23 04:32:26 PDT 2017


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

            Bug ID: 32391
           Summary: Optimization flag -O2 gives wrong results for SSE2 and
                    AVX intrinsics
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: daniel.arndt at iwr.uni-heidelberg.de
                CC: llvm-bugs at lists.llvm.org

Created attachment 18152
  --> https://bugs.llvm.org/attachment.cgi?id=18152&action=edit
Failing test case

The attached code in 'symmetric_tensor_39_reduced.cc' gives wrong output if
optimization flags are used.

The expected output is
B[0][0][0]: 6
B[0][0][1]: 7
B[0][1][0]: 6
B[0][1][1]: 7
B[0][2][0]: 0
B[0][2][1]: 0
B[1][0][0]: 6
B[1][0][1]: 7
B[1][1][0]: 6
B[1][1][1]: 7
B[1][2][0]: 0
B[1][2][1]: 0
B[2][0][0]: 0
B[2][0][1]: 0
B[2][1][0]: 0
B[2][1][1]: 0
B[2][2][0]: 6
B[2][2][1]: 7
while the failing output is
B[0][0][0]: 0
B[0][0][1]: 0
B[0][1][0]: 0
B[0][1][1]: 0
B[0][2][0]: 0
B[0][2][1]: 0
B[1][0][0]: 0
B[1][0][1]: 0
B[1][1][0]: 0
B[1][1][1]: 0
B[1][2][0]: 0
B[1][2][1]: 0
B[2][0][0]: 0
B[2][0][1]: 0
B[2][1][0]: 0
B[2][1][1]: 0
B[2][2][0]: 0
B[2][2][1]: 0

It fails with -O2 for 
-clang version 5.0.0 (trunk 295600)
-clang 4.0.0 rc2
-clang 3.9.1
-clang 3.7.1
-clang 3.6.0
while working with -O1 and -O3.

Fails on
-clang 3.5.0 with -O2 and -O3
-clang 3.4 with -O2 and -O3
while working with -O1

Works for -O1, -O2 and -O3 on
-clang 3.8.1
-clang 3.3
-clang 3.2
-clang 3.1

If 
  SymmetricTensor<4,dim,VectorizedArray> I;
  SymmetricTensor<2,dim,VectorizedArray> A;
  SymmetricTensor<2,dim,VectorizedArray> B;
is changed to
  SymmetricTensor<4,dim,double> I;
  SymmetricTensor<2,dim,double> A;
  SymmetricTensor<2,dim,double> B;
and the loops over v are omitted (symmetric_tensor_39_double.cc), the output is
the same for -O1, -O2 and -O3 on clang-4.0.0rc2. Hence, it seems related to
vector intrinsics.
If A is filled in a separate function, there is no difference as well.

Some detective work can also be found at
https://github.com/dealii/dealii/pull/4058.

-- 
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/20170323/e2b6dcfb/attachment.html>


More information about the llvm-bugs mailing list