From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31175 invoked by alias); 7 Apr 2006 20:16:43 -0000 Received: (qmail 31158 invoked by uid 22791); 7 Apr 2006 20:16:41 -0000 X-Spam-Check-By: sourceware.org Received: from Unknown (HELO greg.sparky.org) (71.115.227.235) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 07 Apr 2006 20:16:35 +0000 Received: by greg.sparky.org (Postfix, from userid 1000) id 7C489A00CF; Fri, 7 Apr 2006 13:17:05 -0700 (PDT) Date: Fri, 07 Apr 2006 20:16:00 -0000 From: Greg Buchholz To: gcc-help@gcc.gnu.org Subject: Re: GCC Vector Extensions Message-ID: <20060407201705.GA1816@sleepingsquirrel.org> Mail-Followup-To: gcc-help@gcc.gnu.org References: <200604072057.54623.cuse@users.sourceforge.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200604072057.54623.cuse@users.sourceforge.net> User-Agent: Mutt/1.4.2.1i X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2006-04/txt/msg00052.txt.bz2 Christian Schoenebeck wrote: > 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 /* I don't know if this qualifies as good, but here's some things I've used before */ #include #include #include typedef float v4sf __attribute__ ((vector_size (16))); int main() { v4sf a,b,c; float *z; ((float *)&a)[0] = 1.0; ((float *)&a)[1] = 2.0; ((float *)&a)[2] = 3.0; ((float *)&a)[3] = 4.0; memcpy((float *)&b,(float[]){0.5,0.6,0.7,0.8},4*sizeof(float)); c = a + b; z = (float *)&c; printf("%f, %f, %f, %f\n", *z, *(z+1), z[2], z[3]); return 0; }