[LLVMdev] [CLang] Comparing vector types - invalid error and proposed fix
Martin O'Riordan
Martin.ORiordan at movidius.com
Thu Oct 3 00:41:34 PDT 2013
Thanks Mark, hadn't spotted the CLang distribution list.
MartinO
-----Original Message-----
From: Mark Lacey [mailto:mark.lacey at apple.com]
Sent: 02 October 2013 22:50
To: Martin.ORiordan at movidius.com
Cc: LLVM Developers Mailing List
Subject: Re: [LLVMdev] [CLang] Comparing vector types - invalid error and
proposed fix
Hi Martin,
On Oct 2, 2013, at 6:25 AM, Martin O'Riordan <Martin.ORiordan at movidius.com>
wrote:
> I was investigating an error diagnostic in the following test example:
>
> typedef signed char char16 __attribute__((ext_vector_type(16)));
>
> void test( char16 srcA, char16 srcB, char16 *dst) {
> *dst = ( srcA == srcB );
> }
>
> which produces the message:
>
> mismatch.c:5:10: error: assigning to 'char16' from incompatible type
> 'char __attribute__((ext_vector_type(16)))'
> *dst = ( srcA == srcB );
> ^ ~~~~~~~~~~~~~~~~
> 1 error generated.
>
> There appear to be two things going on here. The first is the notion
> of compatible types which are not supported by GCC/CLang for vector
> extensions, even in the trivial case where 'signed char' == 'char' (in C).
The right place to discuss clang issues is cfe-dev at cs.uiuc.edu.
Having said that, in C/C++, char, signed char, and unsigned char are three
distinct types, so I don't think your proposed fix below is correct.
>
> The second thing is that the result of a comparison between two
> vectors is supposed to result in the a 'signed' integer vector result.
>
> 'char' is always troublesome, though in C++ it is a discrete type. I
> made the following change in my copy (clang-3.3) that I think is a
> correct and valid change:
>
> File: tools/clang/lib/Sema/SemaChecking.cpp
> Function: Sema::GetSignedVectorType()
>
> Replace the fragment:
>
> if (TypeSize == Context.getTypeSize(Context.CharTy))
> return Context.getExtVectorType(Context.CharTy,
> VTy->getNumElements());
> ^^^^^^
> with:
> if (TypeSize == Context.getTypeSize(Context.CharTy))
> return Context.getExtVectorType(Context.SignedCharTy,
> VTy->getNumElements());
> ^^^^^^^^^^^^
>
> I would like to propose this as a fix for a future release of CLang.
>
> Thanks,
>
> Martin O'Riordan - Movidius Ltd.
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list