This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] prototype altivec function overloading rewrite



If you have opaque return types, or any type chosen too early, you won't
select the proper vector addition instruction for one or the other of
the outer-most calls.


No, you can because rs6000_fold_builtin will return the expansion of the proper vector addition builtin, with the proper return type that is used for the outermost calls. All the following calls are expanded properly with my approach:


vector unsigned char w; vector unsigned int z; vector bool int y; vector int x;

char a[vec_step (x)];

void f ()
{
 w = vec_add (w, w); /* pick addubm */
}

void g ()
{
 vec_dst (&x, 1, 0);

 x = vec_add (y, x);   /* pick adduwm */
 z = vec_adds (z, z);  /* pick adduws */

 x = vec_adds (x, x);  /* pick addsws */
 x = vec_adds (y, x);  /* pick addsws */
}

void h ()
{
 x = vec_adds (vec_adds (x, x), vec_adds (x, x)); /* pick three addsws */
}

void i ()
{
 z = vec_adds (vec_adds (z, z), vec_adds (z, z)); /* pick three adduws */
}

void j ()
{
w = (vector unsigned char) vec_add ((vector unsigned int) w, (vector unsigned int) w); /* pick adduwm */
}


void k ()
{
w = (vector unsigned char) vec_add ((vector unsigned short) w, (vector unsigned short) w); /* pick adduhm */
}


I still have to work out how to do the predicates, and to sort out languages other than C, but the rest is already in place.

I wouldn't be opposed to a fold_builtin hook, but that would have to
get used for actual folding, i.e. when the builtin gets fed constant
values.


I agree that this would be an abuse of fold_builtin.

True enough. And probably we can use bitfields in the structures
to make it pack smaller in memory.


Less than 10 kb (8 bytes * ~1000 entries).

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]