<html>
    <head>
      <base href="http://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 --- - Code generation problem with Altivec vec_sel intrinsic"
   href="http://llvm.org/bugs/show_bug.cgi?id=16641">16641</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Code generation problem with Altivec vec_sel intrinsic
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </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>schnetter@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I am encountering a code generation problem likely related to the Altivec
vec_sel intrinsic.

I am using

$ /home/projects/llvm/bin/clang++ -v
clang version 3.4 (login1.mcs.anl.gov:src/llvm-trunk/tools/clang
0a67b3629eee1e58a45415e07d1bfcd908d73c77) (login1.mcs.anl.gov:src/llvm-trunk
faa6fb57b03395c8b716b8c7523b4be2760a7820)
Target: powerpc64-unknown-linux-gnu
Thread model: posix

on a Power 7 system. The failing program is a test suite for Vecmathlib
<<a href="http://bitbucket.org/eschnett/vecmathlib/">http://bitbucket.org/eschnett/vecmathlib/</a>>, a library for SIMD vectorization.
When I build it with the options

$ /home/projects/llvm/bin/clang++ -faltivec -o test test.cc

it produces the output

$ ./test | head -n 20
Testing math functions:
Vecmathlib configuration: [conf-DEBUG-Altivec]

Testing math functions for type <Altivec:4*float>:
   testing boolean operations...
Error in ifthen(bool):
   x=[0,1,0,0] [0x00000fffdfb681800000000010003918]
   y=[0,0,0,0] [0x00000000000000000000000000000000]
   z=[0,0,1,1] [0xffffffffffffffff0000000000000000]
   fstd(x,y,z)=[0,0,1,1] [0x00000000000000000000000000000000]
   fvml(x,y,z)=[0,0,0,0] [0x00000000000000000000000000000000]
   error(x,y,z)=[0,0,1,1] [0x00000000000000000000000000000000]
   isbad(x,y,z)=[0,0,1,1]

indicating that a self-test fails; there should be no output starting with
"Error in ...". This particular self-test checks an "ifthen(x,y,z)" function,
which is for Altivec a wrapper around vec_sel, which x the condition (vector of
bool), and y and z the then- and else-values, respectively. As you can see, the
value for x is bogus; this should be a boolean vector, which is on Altivec a
vector of unsigned integers with either all bits unset or all bits set. I
assume there is a code generation problem that corrupts the value for x.

I attach the original source code (files test.cc and vec_altivec_float4.h) as
well as the pre-processed source code test.i.

I expect this pre-processed source code to be built with the command

$ /home/projects/llvm/bin/clang++ -faltivec -o test -x c++-cpp-output test.i

but this leads to the error

In file included from <built-in>:163:
<command line>:1:10: fatal error: 'altivec.h' file not found
#include "altivec.h"
         ^
1 error generated.

which is bogus since there is no #include statement at all in test.i. I hope
that test.i is nevertheless useful.</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>