<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 - Optimization flag -O2 gives wrong results for SSE2 and AVX intrinsics"
   href="https://bugs.llvm.org/show_bug.cgi?id=32391">32391</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Optimization flag -O2 gives wrong results for SSE2 and AVX intrinsics
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>daniel.arndt@iwr.uni-heidelberg.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18152" name="attach_18152" title="Failing test case">attachment 18152</a> <a href="attachment.cgi?id=18152&action=edit" title="Failing test case">[details]</a></span>
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
<a href="https://github.com/dealii/dealii/pull/4058">https://github.com/dealii/dealii/pull/4058</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>