[cfe-users] clang __builtin_convertvector

Venkata Suneel Kota chanakya.sun at gmail.com
Mon Feb 24 23:10:17 PST 2014


Hi,

I am using builtin_convertvector extension on clang 3.4

my code is as below
int main ()
{
typedef float  vector4float   __attribute__((ext_vector_type(4)));
typedef short  vector4short   __attribute__((ext_vector_type(4)));
  vector4float vf;
    vector4short vs;

    vs.s0 = 0;
    vs.s1 = 2134;
    vs.s2 = 654;
    vs.s3 = 252;

    vf.s0 = 234.234f;
    vf.s1 = 1234.54f;
    vf.s2 = 654.32f;
    vf.s3 = 252.98f;

    printf("OLD: %d %d %d %d \n", vs.s0, vs.s1, vs.s2, vs.s3);

    vs = __builtin_convertvector(vf, vector4short);
    printf("INPUT %f %f %f %f \n", vf.s0, vf.s1, vf.s2, vf.s3);
    printf("OUTPUT %d %d %d %d \n", vs.s0, vs.s1, vs.s2, vs.s3);

}


the output is as below
OLD 0 2134 654 252
INPUT 234.233994 1234.540039 654.320007 252.979996
OUTPUT 234 1234 654 252

if i ask for rounding mode using fgetround
it gave output "rounding using to-nearest"

It can be seen from the output that, it is truncated integer part of float
value
can i change the rounding mode for __builtin_convertvector

how about when the limits of short are reached?


Thanks & Regards
Suneel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20140225/1da228ac/attachment.html>


More information about the cfe-users mailing list