From patchwork Tue Apr 12 14:34:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 984 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:48:00 -0000 Delivered-To: patches@linaro.org Received: by 10.68.59.138 with SMTP id z10cs188564pbq; Tue, 12 Apr 2011 07:34:22 -0700 (PDT) Received: by 10.227.7.87 with SMTP id c23mr6529303wbc.108.1302618861211; Tue, 12 Apr 2011 07:34:21 -0700 (PDT) Received: from mail-wy0-f178.google.com (mail-wy0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id d10si13155273wbh.68.2011.04.12.07.34.20 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Apr 2011 07:34:21 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of richard.sandiford@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of richard.sandiford@linaro.org) smtp.mail=richard.sandiford@linaro.org Received: by wyb33 with SMTP id 33so6880326wyb.37 for ; Tue, 12 Apr 2011 07:34:20 -0700 (PDT) Received: by 10.227.179.140 with SMTP id bq12mr6949749wbb.152.1302618860553; Tue, 12 Apr 2011 07:34:20 -0700 (PDT) Received: from richards-thinkpad (gbibp9ph1--blueice2n1.emea.ibm.com [195.212.29.75]) by mx.google.com with ESMTPS id x1sm4075958wbh.36.2011.04.12.07.34.18 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Apr 2011 07:34:19 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, patches@linaro.org, richard.sandiford@linaro.org Cc: patches@linaro.org Subject: [10/9] Add tests for stride-3 accesses References: Date: Tue, 12 Apr 2011 15:34:17 +0100 In-Reply-To: (Richard Sandiford's message of "Tue, 12 Apr 2011 14:20:54 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 This patch adds a test for stride-3 accesses. I didn't add any particularly complicated cases because I think the testsuite already covers the interaction between the strided loads & stores and other operations pretty well. Let me know if there's something I should add though. Tested on x86_64-linux-gnu and arm-linux-gnueabi. OK to install? Richard gcc/testsuite/ * gcc.dg/vect/vect-strided-u16-i3.c: New test. Index: gcc/testsuite/gcc.dg/vect/vect-strided-u16-i3.c =================================================================== --- /dev/null 2011-03-23 08:42:11.268792848 +0000 +++ gcc/testsuite/gcc.dg/vect/vect-strided-u16-i3.c 2011-04-12 11:55:17.000000000 +0100 @@ -0,0 +1,112 @@ +#include +#include "tree-vect.h" + +#define N 128 + +typedef struct { + unsigned short a; + unsigned short b; + unsigned short c; +} s; + +#define A(I) (I) +#define B(I) ((I) * 2) +#define C(I) ((unsigned short) ~((I) ^ 0x18)) + +void __attribute__ ((noinline)) +check1 (s *res) +{ + int i; + + for (i = 0; i < N; i++) + if (res[i].a != C (i) + || res[i].b != A (i) + || res[i].c != B (i)) + abort (); +} + +void __attribute__ ((noinline)) +check2 (unsigned short *res) +{ + int i; + + for (i = 0; i < N; i++) + if (res[i] != (unsigned short) (A (i) + B (i) + C (i))) + abort (); +} + +void __attribute__ ((noinline)) +check3 (s *res) +{ + int i; + + for (i = 0; i < N; i++) + if (res[i].a != i + || res[i].b != i + || res[i].c != i) + abort (); +} + +void __attribute__ ((noinline)) +check4 (unsigned short *res) +{ + int i; + + for (i = 0; i < N; i++) + if (res[i] != (unsigned short) (A (i) + B (i))) + abort (); +} + +void __attribute__ ((noinline)) +main1 (s *arr) +{ + int i; + s *ptr = arr; + s res1[N]; + unsigned short res2[N]; + + for (i = 0; i < N; i++) + { + res1[i].a = arr[i].c; + res1[i].b = arr[i].a; + res1[i].c = arr[i].b; + } + check1 (res1); + + for (i = 0; i < N; i++) + res2[i] = arr[i].a + arr[i].b + arr[i].c; + check2 (res2); + + for (i = 0; i < N; i++) + { + res1[i].a = i; + res1[i].b = i; + res1[i].c = i; + } + check3 (res1); + + for (i = 0; i < N; i++) + res2[i] = arr[i].a + arr[i].b; + check4 (res2); +} + +int main (void) +{ + int i; + s arr[N]; + + check_vect (); + + for (i = 0; i < N; i++) + { + arr[i].a = A (i); + arr[i].b = B (i); + arr[i].c = C (i); + } + main1 (arr); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target vect_strided3 } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */