how to detect that the vector extension is available

Ian Lance Taylor iant@google.com
Thu Sep 29 07:30:00 GMT 2011


Vincent Torri <vtorri@univ-evry.fr> writes:

> I want to write an autoconf test to see if the vector extension is
> available or not.
>
> if I have
>
> typedef int v4si __attribute__ ((vector_size (16)));
>
> I can check the size of v4si.
>
> I'm wondering if it's sufficient. Indeed, with my gcc 4.4.5, the size
> of v4si is 16 bytes, but the code in the doc [1]:
>
> v4si a, b;
> a=b+1;
>
> fails with error "can't convert between vector values of different
> size". With gcc 4.7, it  works.
>
> So :
>
> 1) from which version of gcc is the addition with a scalar possible
> (just for my curiosity)

It's new in the upcoming gcc 4.7.


> 2) is checking the size sufficient to be sure that the extension is
> available ?

The vector extension, yes.


> 3) is there better code for such check ?

I guess it depends on exactly what you want to check.  With current gcc
vector_size will work even if the target does not actually support
vectors in hardware.  So if you want to check whether you can use
vectors in your code this test will suffice.  If you want to check
whether you will actually get any hardware speedup, you will need a
different check.

Ian



More information about the Gcc-help mailing list