[cfe-dev] problems with vector code

Nate Begeman natebegeman at me.com
Tue Mar 23 10:57:05 PDT 2010


On Mar 23, 2010, at 10:32 AM, Anton Lokhmotov wrote:

>> sorry, I didn't have altivec enabled and didn't know that it has to be
>> enabled also for cl style vector casts.
>> therefore (float4)(a,b,c,d) compiles comma operators, i.e. (float4)(d).
> 
> ...which is not would you expect when you explicitly request
> AltiVec-support! (Hence my bug report:
> http://llvm.org/bugs/show_bug.cgi?id=6412)
> 
> This has also reminded me of another gripe I have.  
> 
> Could anyone tell me please why Clang compiles this
> 
> typedef float float4 __attribute__((ext_vector_type(4)));
> float4 vadd4(float4 a, float4 b) { return a+b; }
> 
> into
> 
> define <2 x double> @vadd4(<2 x double>, <2 x double>) nounwind {
> 
> ???
> 
> Note that <4 x float> is converted to <2 x double> even when
> cgOpts.OptimizationLevel=0,  cgOpts.DisableLLVMOpts=1.  But e.g. float17
> compiles as expected?

That would probably be because you're compiling for x86-64 and the x86-64 ABI handling code canonicalizes vector types to <2 x double> for argument passing.

Nate




More information about the cfe-dev mailing list