From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25005 invoked by alias); 31 Dec 2009 02:37:40 -0000 Received: (qmail 24990 invoked by uid 22791); 31 Dec 2009 02:37:40 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from nwd2mail11.analog.com (HELO nwd2mail11.analog.com) (137.71.25.57) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 31 Dec 2009 02:37:36 +0000 Received: from nwd2hubcas1.ad.analog.com ([10.64.73.29]) by nwd2mail11.analog.com with ESMTP; 30 Dec 2009 21:37:34 -0500 Received: from nwd2exm5.ad.analog.com (10.64.51.20) by NWD2HUBCAS1.ad.analog.com (10.64.73.29) with Microsoft SMTP Server id 8.1.358.0; Wed, 30 Dec 2009 21:37:34 -0500 Received: from nwd2exm20.ad.analog.com ([10.64.73.20]) by nwd2exm5.ad.analog.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 30 Dec 2009 21:37:34 -0500 Received: from chinexm1.ad.analog.com ([10.99.27.42]) by nwd2exm20.ad.analog.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 30 Dec 2009 21:37:33 -0500 Received: from [10.99.29.107] ([10.99.29.107]) by chinexm1.ad.analog.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 31 Dec 2009 10:37:30 +0800 Message-ID: <4B3C0E6A.2070706@analog.com> Date: Thu, 31 Dec 2009 09:36:00 -0000 From: Jie Zhang User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Lightning/1.0pre Shredder/3.0 MIME-Version: 1.0 To: Benjamin Redelings I CC: gcc-help@gcc.gnu.org Subject: Re: Correct way to make a 16-byte aligned double* for SSE vectorization? References: <4B3BAA3E.80802@ncsu.edu> In-Reply-To: <4B3BAA3E.80802@ncsu.edu> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2009-12/txt/msg00383.txt.bz2 Hi, On 12/31/2009 03:30 AM, Benjamin Redelings I wrote: > Hi, > > I am trying to figure out how to make a double* that is 16-byte aligned > in the way that SSE instructions want. Hopefully this would allow GCC to > auto-vectorize loops in a better way. The problem that I am having is > that I want a pointer to an aligned double, not an aligned pointer to a > double. > > I am compiling with these options: > % gcc -c test.C -O3 -ftree-vectorizer-verbose=3 -ffast-math > > According to the output of the vectorizer, none of the three ways > (below) of declaring an aligned pointer actually work. They are treated > as unaligned accesses, so presumably the location of the pointer itself > is being aligned, but it does not point to an aligned location. In > contrast, if I define an aligned double, and then define a pointer to > it, this works. Is this recommended? > Below is just taken from the GCC Manual: [quote] As another example, char *__attribute__((aligned(8))) *f; specifies the type “pointer to 8-byte-aligned pointer to char”. Note again that this does not work with most attributes; for example, the usage of `aligned' and `noreturn' attributes given above is not yet supported. [/quote] If it had been supported, you could use > //typedef const real __attribute__((aligned(16))) *SSE_PTR; But since it is not yet supported now, you have to use > typedef double real; > > // these two lines work (together) > typedef real aligned_real __attribute__((aligned(16))); > typedef const aligned_real* SSE_PTR; > Jie