problems with vector code

Hi!

when playing with the builtin vectors (ext_vector_type) I have some problems.
My codeGenOptions bypass all optimizations:

clang::CodeGenOptions codeGenOptions;
codeGenOptions.DisableLLVMOpts = 1;
codeGenOptions.OptimizationLevel = 0;
codeGenOptions.Inlining = clang::CodeGenOptions::NormalInlining;

I have a function with this prototype: float4 foo(float4 y)

**Test case 1 (works):

return (float4)(y);

yiels:

  ret <4 x float> %y

**Test case 2 (fails):

return (float4)(y.x, y.y, y.z, y.w);

yields:

%tmp1 = extractelement <4 x float> %y, i32 0 ; <float> [#uses=0]
   %tmp3 = extractelement <4 x float> %y, i32 1 ; <float> [#uses=0]
   %tmp5 = extractelement <4 x float> %y, i32 2 ; <float> [#uses=0]
   %tmp7 = extractelement <4 x float> %y, i32 3 ; <float> [#uses=1]
   %tmp8 = insertelement <4 x float> undef, float %tmp7, i32 0 ; <<4 x

[#uses=2]

   %splat = shufflevector <4 x float> %tmp8, <4 x float> %tmp8, <4 x i32> zeroinitializer ; <<4 x float>> [#uses=1]
   ret <4 x float> %splat

**Test case 3 (fails):

return (float4)(y.xyz, y.w);

yields:

  %tmp1 = shufflevector <4 x float> %y, <4 x float> undef, <3 x i32> <i32 0, i32 1, i32 2> ; <<3 x float>> [#uses=0]
   %tmp3 = extractelement <4 x float> %y, i32 3 ; <float> [#uses=1]
   %tmp4 = insertelement <4 x float> undef, float %tmp3, i32 0 ; <<4 x

[#uses=2]

   %splat = shufflevector <4 x float> %tmp4, <4 x float> %tmp4, <4 x i32> zeroinitializer ; <<4 x float>> [#uses=1]
   ret <4 x float> %splat

**Test case 4 (does not compile):

return (float4)(y.x, y.yzw);

Assertion failed: castIsValid(getOpcode(), S, Ty) && "Illegal BitCast", file ..\
..\..\lib\VMCore\Instructions.cpp, line 2719

Sounds bad, please add self contained testcases with info to reproduce to a bugzilla, thanks!

-Chris

Hi!

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).

-Jochen