[llvm-bugs] [Bug 33103] New: Ternary operator not supported using OpenCL style vectors in C++ program while docs imply this is supported.

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 19 10:08:32 PDT 2017


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

            Bug ID: 33103
           Summary: Ternary operator not supported using OpenCL style
                    vectors in C++ program while docs imply this is
                    supported.
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: OpenCL
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zalman at google.com
                CC: llvm-bugs at lists.llvm.org

The table at:
    https://clang.llvm.org/docs/LanguageExtensions.html#vector-operations
seems to be a list of which operators work with vectors declared as a certain
type of vector in clang. That is if I declare an OpenCL style vector, I would
expect the operators under the OpenCL column to work. The ternary operator does
not appear to work as it would in OpenCL.

The following program:
[
typedef int int4  __attribute__((ext_vector_type(4)));
typedef float float2  __attribute__((ext_vector_type(2)));
typedef float float4  __attribute__((ext_vector_type(4)));

// This compiles, indicating OpenCL extensions are at least partially supported
by default
float2 test_vec_components(float4 input) {
    return input.xy;
}

float4 test_ternary(float4 a, float4 b, int4 mask) {
  return mask ? a  : b;
}
]

gives the error:
[
/tmp/llvm_bug.cpp:10:10: error: value of type 'int4' (vector of 4 'int' values)
is not contextually convertible to 'bool'
  return mask ? a  : b;
]

Either the table above should be clarified or this error should not arise.

Note also the latest version of gcc supports the ternary operator using its
vector extensions. There are likely other bugs to be filed on clang's support
for gcc style vectors not matching what the latest gcc does, but I'm not well
versed enough in the goals to do so.

Clang version:

clang version 5.0.0 (http://llvm.org/git/clang.git
ea3a0ef86d3f4d8f859f9eca4ef97134484c2610) (http://llvm.org/git/llvm.git
7d7f10bcdd4eeade10d64fee424260318f624127)
Target: x86_64-unknown-linux-gnu

-- 
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/20170519/c64ce649/attachment.html>


More information about the llvm-bugs mailing list