[llvm-bugs] [Bug 44241] New: [PowerPC] Compile error when including x86 vector intrinsics compatibility headers in C++

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Dec 6 08:14:36 PST 2019


            Bug ID: 44241
           Summary: [PowerPC] Compile error when including x86 vector
                    intrinsics compatibility headers in C++
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Headers
          Assignee: unassignedclangbugs at nondot.org
          Reporter: colin.samples at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    nemanja.i.ibm at gmail.com, richard-llvm at metafoo.co.uk

Created attachment 22915
  --> https://bugs.llvm.org/attachment.cgi?id=22915&action=edit
Patch to fix typedefs

On ppc64le, this can be reproduced with:

    $ echo -e "#include <xmmintrin.h>\nint main() {}" > test1.cpp
    $ clang++ test.cpp -DNO_WARN_X86_INTRINSICS

And results in the following error:

error: controlling expression type '__v4sf' (vector of 4 'float' values) not
compatible with any generic association type
      result = (__vector unsigned long long) vec_cts (rounded, 0);
note: expanded from macro 'vec_cts'
      _Generic((__a), vector float                                             

This also affects Clang 9.

The issue occurs because the `*mmintrin.h` PPC compatibility headers define
typedefs to map the Intel vector types to the AltiVec types. The typedefs use
the `__vector_size__` type attribute instead of the `__vector` keyword.

`altivec.h` uses C11 generics for  `vec_ctf`, `vec_cts`, `vec_ctu`,
`vec_shasigma_be`, and `vec_test_data_class`. Per the docs:

    In C, type compatibility is decided according to the rules given in
    the appropriate standard, but in C++, which lacks the type
    compatibility rules used in C, types are considered compatible only
    if they are equivalent.

Use of these functions in C++ programs with the `*mmintrin.h` typedef results
in the same compiler error. Note that the `vec_ct*` will not work with
`__vector float` until bug #44239 is resolved.

See attached for a patch that changes the typedefs to use the `__vector`
keyword.  Not sure if this is the best approach, since this fixes the issue for
the compatibility headers but not for user specified typedefs using

Another option I worked up would be to create overload sets for C++, as in the
second attachment.

But let me know if you would like me to work this up further or if there is a
better way.

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/20191206/e62840ca/attachment.html>

More information about the llvm-bugs mailing list