This is the mail archive of the 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: Vector indexing patch

On Tue, Jun 1, 2010 at 9:21 PM, Artem Shinkarov
<> wrote:
> This is a reworked patch of Andrew Pinski "Subscripting on vector
> types" in terms of GSoC 2010 [Artjoms Sinkarovs].
> This patch allows to index individual elements of vector type in C.
> For example: vec[i], where vec is a vector with a base type T and i is
> an integer type.
> If i is a constant then we construct a BIT_FIELD_REF node considering
> boundchecking, otherwise we expand it to (((T *)&(vec))[i]).
> If the vector type variable has a register storage class then it can
> be accessed only via constant index.
> Changelog:
> gcc/c-common.h: helper function c_build_vector_indexed_by_cst added
> gcc/c-common.c: helper function c_build_vector_indexed_by_cst added
> gcc/c-typeck.c: build_array_ref modified to handle vector indexing,
> lvalue_p modified for considering vector element as lvalue.
> gcc/testsuite/gcc.c-torture/execute/vector-subscript-1.c: test taken
> from A.Pinski patch
> gcc/testsuite/gcc.c-torture/execute/vector-subscript-2.c: test taken
> from A.Pinski patch
> gcc/testsuite/gcc.dg/vector-subscript-3.c: new test
> gcc/testsuite/gcc.dg/array-8.c: Update error message about subscripting
> gcc/testsuite/gcc.dg/vector-subscript-1.c: test taken from A.Pinski patch
> gcc/testsuite/gcc.dg/vector-subscript-2.c: test taken from A.Pinski patch

A properly formatted ChangeLog entry would look like

2010-06-05  Artem Shinkarov <>
        Andrew Pinski <>

        * c-common.h (c_build_vector_indexed_by_cst): Declare.
        * c-common.c (c_build_vector_indexed_by_cst): New function.
        * c-typeck.c (build_array_ref): Handle subscripting of vectors.
        (lvalue_p): BIT_FIELD_REFs of vectors are lvalues.

        * gcc.c-torture/execute/vector-subscript-1.c: New testcase.
        * gcc.c-torture/execute/vector-subscript-2.c: Likewise.
        * gcc.dg/vector-subscript-3.c: Likewise.
        * gcc.dg/vector-subscript-1.c: Likewise.
        * gcc.dg/vector-subscript-2.c: Likewise.
        * gcc.dg/array-8.c: Adjust.

the first part goes into gcc/ChangeLog and the 2nd part into
gcc/testsuite/ChangeLog when the patch is committed.

Please also include the documentation changes to gcc/doc/extend.texi
into the patch (and adjust it as appropriate).

As I mentioned in the reply to Andrew we decided to follow OpenCL
where possible instead of the Cell spec.


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