public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC Vector Extensions
@ 2006-04-07 19:03 Christian Schoenebeck
  2006-04-07 20:16 ` Greg Buchholz
  0 siblings, 1 reply; 18+ messages in thread
From: Christian Schoenebeck @ 2006-04-07 19:03 UTC (permalink / raw)
  To: gcc-help; +Cc: linuxsampler-devel

Hi!

I just read the GCC Vector Extensions doc [1] and have a few questions.

a) The last code block in that doc [1] uses "builtin" functions? Why should
somebody use those builtin functions when the normal C operations on the new
vector extension types do the same?

b) We wondered [2] what the currently best way is to access single elements of
one vector. Currently the only solution we saw is to use a union trick like:

typedef struct {
        float _1;
        float _2;
        float _3;
        float _4;
} quad_samples;

typedef float v4sf __attribute__ ((vector_size (16)));

typedef union {
        quad_samples s;
        v4sf v;
} quad_sample_t;

Is there a better way to access single elements of a vector?

c) What I'm missing a lot (especially for digital signal processing) are (bit)
shifting operations on the new vector types. Are those planned or already in
work?

[1] http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Vector-Extensions.html#Vector-Extensions
[2] https://bugs.linuxsampler.org/cgi-bin/show_bug.cgi?id=25

CU
Christian

^ permalink raw reply	[flat|nested] 18+ messages in thread
* GCC vector extensions.
@ 2010-11-04 16:14 Hariharan Sandanagobalane
  2010-11-04 18:59 ` Ian Lance Taylor
  0 siblings, 1 reply; 18+ messages in thread
From: Hariharan Sandanagobalane @ 2010-11-04 16:14 UTC (permalink / raw)
  To: gcc-help

Hello,
I have a feeling the website is wrong. If you went to 
http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html, it claims

"In C vectors can be subscripted as if the vector were an array with the 
same number of elements and base type. Out of bound accesses invoke 
undefined behavior at runtime. Warnings for out of bound accesses for 
vector subscription can be enabled with -Warray-bounds. "

I went through the gcc source code and the extend.texi does not have 
this statement anymore. Why is that not reflected on the website?

When i tried that in a simple example.

#define vector __attribute__((vector_size(16) ))

static inline vector int vectadd(vector int t1, vector int t2)
{
  return t1 + t2;
}

vector int a = {0, 1, 0, 1, 0, 0, 0, 0};
vector int b = {0, 0, 1, 1, 0, 0, 0, 0};
vector int c = {0, 1, 1, 0, 0, 0, 0, 0};
int main(void)
{
   vector int a0;
   a0 = vectadd(a, b);
   if (a0[2] != 1)
     __builtin_abort ();
   return 0;
}

I get a compiler error "error: subscripted value is neither array nor 
pointer".

Cheers
Hari

^ permalink raw reply	[flat|nested] 18+ messages in thread
* Gcc vector extensions
@ 2011-02-28 23:37 Hari Sandanagobalane
  2011-02-28 23:55 ` Ian Lance Taylor
  0 siblings, 1 reply; 18+ messages in thread
From: Hari Sandanagobalane @ 2011-02-28 23:37 UTC (permalink / raw)
  To: gcc-help

Hello,
Picochip processor has a vector unit that supports operations such as

ADD imm,vsrc,vdest.

where you can add a scalar value to a vector register. This is 
equivalent to adding every element of the vector register with the 
scalar value.

GCC vector extensions allow for a scalar to be used for shift 
operations. This example from documentation says

      typedef int v4si __attribute__ ((vector_size (16)));

      v4si a, b;

      b = a >> 1;     /* b = a >> {1,1,1,1}; */

Is it possible to support

b = a + 1 /* b = a + {1,1,1,1} */

Or, is there any other way to represent this operation?

Thanks for your help.

Cheers
Hari

Note: I am not sure whether this is the right mailing list for this 
discussion.

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2011-02-28 23:37 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-07 19:03 GCC Vector Extensions Christian Schoenebeck
2006-04-07 20:16 ` Greg Buchholz
2006-04-15  0:58   ` Christian Schoenebeck
2006-04-18 10:04     ` Andrew Haley
2006-04-18 23:38       ` Christian Schoenebeck
2006-04-19  8:30         ` Andrew Haley
2006-04-19 12:19           ` Christian Schoenebeck
2006-04-19 13:13             ` John Love-Jensen
2006-04-19 14:03             ` Andrew Haley
2006-04-19 15:20               ` Andrew Haley
2006-04-19 20:05                 ` Christian Schoenebeck
2006-04-19 20:25                   ` Andrew Haley
2006-04-19 14:58             ` [Linuxsampler-devel] " Harri Järvi
2006-04-19 15:14               ` Brian Budge
2010-11-04 16:14 GCC vector extensions Hariharan Sandanagobalane
2010-11-04 18:59 ` Ian Lance Taylor
2011-02-28 23:37 Gcc " Hari Sandanagobalane
2011-02-28 23:55 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).