[cfe-dev] problems with vector code
Jochen Wilhelmy
j.wilhelmy at arcor.de
Tue Mar 23 04:37:40 PDT 2010
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
float>> [#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
float>> [#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
More information about the cfe-dev
mailing list