From patchwork Tue Dec 20 03:02:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sawdey X-Patchwork-Id: 88533 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1509328qgi; Mon, 19 Dec 2016 19:03:00 -0800 (PST) X-Received: by 10.98.15.206 with SMTP id 75mr17437752pfp.105.1482202980084; Mon, 19 Dec 2016 19:03:00 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l11si7214296pli.113.2016.12.19.19.02.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Dec 2016 19:03:00 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-444820-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-444820-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-444820-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:date:content-type:mime-version:message-id; q=dns; s=default; b=b86s4Zy/CV+fPkvglv7+YznXgHbl1MsPjRoak7M8ZRJ KWcwvUGxYv93FHhovhOMjRKPcvKHxCiNk8kv+ItBdc9V8dO8+icDXHQuu3FcEdW/ VRH5VR05/y0v8vh1X/stP3JqiTTQibm6eZx5kuPho2jW4kSsTNHRXSmb0Vy5dE3E = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:date:content-type:mime-version:message-id; s=default; bh=bLjjBsXFi0SkBmiC5b4SpdwbQb0=; b=XD2/HHUBXB34OTJro vp9A4BWS07+kZtbwU4WBpZ8LjdUcQdsIVfTKiFWz/9TKkTF8JALYETXbQW+NVxdC H7kXNomCbrlnZBB/TLzo1zkaCb/JPYA4mfUUup061jWAv0WTYQulVZnb/mImg4id FA4QaWjqiEDQSpuSPQYjfdqYYM= Received: (qmail 94291 invoked by alias); 20 Dec 2016 03:02:31 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 94272 invoked by uid 89); 20 Dec 2016 03:02:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.0 required=5.0 tests=AWL, BAYES_20, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, UPPERCASE_50_75 autolearn=no version=3.3.2 spammy=sn, 91, 5, 8, phd X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Dec 2016 03:02:26 +0000 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uBK2xCgF131470 for ; Mon, 19 Dec 2016 22:02:25 -0500 Received: from e19.ny.us.ibm.com (e19.ny.us.ibm.com [129.33.205.209]) by mx0a-001b2d01.pphosted.com with ESMTP id 27egf421r8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 19 Dec 2016 22:02:24 -0500 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 19 Dec 2016 22:02:24 -0500 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e19.ny.us.ibm.com (146.89.104.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 19 Dec 2016 22:02:21 -0500 Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 605A66E803C; Mon, 19 Dec 2016 22:01:54 -0500 (EST) Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uBK32LtQ20709768; Tue, 20 Dec 2016 03:02:21 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E630112034; Mon, 19 Dec 2016 22:02:21 -0500 (EST) Received: from ragesh3a (unknown [9.85.129.212]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 6DCEE112047; Mon, 19 Dec 2016 22:02:20 -0500 (EST) Subject: [PATCH] Add testcases to test builtin-expansion of memcmp and strncmp From: Aaron Sawdey To: "gcc-patches@gcc.gnu.org" Cc: Richard Biener , Kaz Kojima , olegendo@gcc.gnu.org, Nick Clifton , Jeff Law , David Edelsohn Date: Mon, 19 Dec 2016 21:02:19 -0600 Mime-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16122003-0056-0000-0000-000002426D6E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006281; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000198; SDB=6.00796278; UDB=6.00386438; IPR=6.00574091; BA=6.00004986; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013661; XFM=3.00000011; UTC=2016-12-20 03:02:23 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16122003-0057-0000-0000-000006777258 Message-Id: <1482202939.5501.13.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-19_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1612200037 X-IsSubscribed: yes This patch adds tests gcc.dg/memcmp-1.c and gcc.dg/strncmp-1.c that test builtin expansion of memcmp and strncmp for short strings and also varying alignment of one arg. The strncmp test checks that things work when one of the strings crosses a 4k boundary as well. I've included interested parties from targets that have a strncmp builtin. The tests pass on ppc64le and x86_64. OK for trunk? -- Aaron Sawdey, Ph.D. acsawdey@linux.vnet.ibm.com 050-2/C113 (507) 253-7520 home: 507/263-0782 IBM Linux Technology Center - PPC Toolchain Index: gcc/testsuite/gcc.dg/memcmp-1.c =================================================================== --- gcc/testsuite/gcc.dg/memcmp-1.c (revision 0) +++ gcc/testsuite/gcc.dg/memcmp-1.c (working copy) @@ -0,0 +1,612 @@ +/* Test memcmp builtin expansion for compilation and proper execution. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +#include +#include +#include + +#define RUN_TEST(SZ, ALIGN) test_memcmp_ ## SZ ## _ ## ALIGN () + +#define DEF_TEST(SZ, ALIGN) \ +static void test_memcmp_ ## SZ ## _ ## ALIGN (void) { \ + char one[3 * (SZ > 10 ? SZ : 10)]; \ + char two[3 * (SZ > 10 ? SZ : 10)]; \ + int i,j; \ + for (i = 0 ; i < SZ ; i++) \ + { \ + int r1; \ + char *a = one + (i & 1) * ALIGN; \ + char *b = two + (i & 1) * ALIGN; \ + memset (a, '-', SZ); \ + memset (b, '-', SZ); \ + a[i] = '1'; \ + b[i] = '2'; \ + a[SZ] = 0; \ + b[SZ] = 0; \ + if (!((r1 = memcmp (b, a, SZ)) > 0)) \ + { \ + printf("FAIL SZ %d ALIGN %d i=%d b > a r1=%d a='%s' b='%s'n", \ + SZ, ALIGN, i, r1, a, b); \ + abort (); \ + } \ + if (!((r1 = memcmp (a, b, SZ)) < 0)) \ + { \ + printf("FAIL SZ %d ALIGN %d i=%d a < b r1=%d a='%s' b='%s'n", \ + SZ, ALIGN, i, r1, a, b); \ + abort (); \ + } \ + b[i] = '1'; \ + if (!((r1 = memcmp (a, b, SZ)) == 0)) \ + { \ + printf("FAIL SZ %d ALIGN %d i=%d a == b r1=%d a='%s' b='%s'n", \ + SZ, ALIGN, i, r1, a, b); \ + abort (); \ + } \ + for(j = i; j < SZ ; j++) \ + { \ + a[j] = '1'; \ + b[j] = '2'; \ + } \ + if (!((r1 = memcmp (b, a, SZ)) > 0)) \ + { \ + printf("FAIL SZ %d ALIGN %d i=%d b > a r1=%d a='%s' b='%s'n", \ + SZ, ALIGN, i, r1, a, b); \ + abort (); \ + } \ + if (!((r1 = memcmp (a, b, SZ)) < 0)) \ + { \ + printf("FAIL SZ %d ALIGN %d i=%d a < b r1=%d a='%s' b='%s'n", \ + SZ, ALIGN, i, r1, a, b); \ + abort (); \ + } \ + } \ +} + +#ifdef TEST_ALL +DEF_TEST(1,1) +DEF_TEST(1,2) +DEF_TEST(1,4) +DEF_TEST(1,8) +DEF_TEST(1,16) +DEF_TEST(2,1) +DEF_TEST(2,2) +DEF_TEST(2,4) +DEF_TEST(2,8) +DEF_TEST(2,16) +DEF_TEST(3,1) +DEF_TEST(3,2) +DEF_TEST(3,4) +DEF_TEST(3,8) +DEF_TEST(3,16) +DEF_TEST(4,1) +DEF_TEST(4,2) +DEF_TEST(4,4) +DEF_TEST(4,8) +DEF_TEST(4,16) +DEF_TEST(5,1) +DEF_TEST(5,2) +DEF_TEST(5,4) +DEF_TEST(5,8) +DEF_TEST(5,16) +DEF_TEST(6,1) +DEF_TEST(6,2) +DEF_TEST(6,4) +DEF_TEST(6,8) +DEF_TEST(6,16) +DEF_TEST(7,1) +DEF_TEST(7,2) +DEF_TEST(7,4) +DEF_TEST(7,8) +DEF_TEST(7,16) +DEF_TEST(8,1) +DEF_TEST(8,2) +DEF_TEST(8,4) +DEF_TEST(8,8) +DEF_TEST(8,16) +DEF_TEST(9,1) +DEF_TEST(9,2) +DEF_TEST(9,4) +DEF_TEST(9,8) +DEF_TEST(9,16) +DEF_TEST(10,1) +DEF_TEST(10,2) +DEF_TEST(10,4) +DEF_TEST(10,8) +DEF_TEST(10,16) +DEF_TEST(11,1) +DEF_TEST(11,2) +DEF_TEST(11,4) +DEF_TEST(11,8) +DEF_TEST(11,16) +DEF_TEST(12,1) +DEF_TEST(12,2) +DEF_TEST(12,4) +DEF_TEST(12,8) +DEF_TEST(12,16) +DEF_TEST(13,1) +DEF_TEST(13,2) +DEF_TEST(13,4) +DEF_TEST(13,8) +DEF_TEST(13,16) +DEF_TEST(14,1) +DEF_TEST(14,2) +DEF_TEST(14,4) +DEF_TEST(14,8) +DEF_TEST(14,16) +DEF_TEST(15,1) +DEF_TEST(15,2) +DEF_TEST(15,4) +DEF_TEST(15,8) +DEF_TEST(15,16) +DEF_TEST(16,1) +DEF_TEST(16,2) +DEF_TEST(16,4) +DEF_TEST(16,8) +DEF_TEST(16,16) +DEF_TEST(17,1) +DEF_TEST(17,2) +DEF_TEST(17,4) +DEF_TEST(17,8) +DEF_TEST(17,16) +DEF_TEST(18,1) +DEF_TEST(18,2) +DEF_TEST(18,4) +DEF_TEST(18,8) +DEF_TEST(18,16) +DEF_TEST(19,1) +DEF_TEST(19,2) +DEF_TEST(19,4) +DEF_TEST(19,8) +DEF_TEST(19,16) +DEF_TEST(20,1) +DEF_TEST(20,2) +DEF_TEST(20,4) +DEF_TEST(20,8) +DEF_TEST(20,16) +DEF_TEST(21,1) +DEF_TEST(21,2) +DEF_TEST(21,4) +DEF_TEST(21,8) +DEF_TEST(21,16) +DEF_TEST(22,1) +DEF_TEST(22,2) +DEF_TEST(22,4) +DEF_TEST(22,8) +DEF_TEST(22,16) +DEF_TEST(23,1) +DEF_TEST(23,2) +DEF_TEST(23,4) +DEF_TEST(23,8) +DEF_TEST(23,16) +DEF_TEST(24,1) +DEF_TEST(24,2) +DEF_TEST(24,4) +DEF_TEST(24,8) +DEF_TEST(24,16) +DEF_TEST(25,1) +DEF_TEST(25,2) +DEF_TEST(25,4) +DEF_TEST(25,8) +DEF_TEST(25,16) +DEF_TEST(26,1) +DEF_TEST(26,2) +DEF_TEST(26,4) +DEF_TEST(26,8) +DEF_TEST(26,16) +DEF_TEST(27,1) +DEF_TEST(27,2) +DEF_TEST(27,4) +DEF_TEST(27,8) +DEF_TEST(27,16) +DEF_TEST(28,1) +DEF_TEST(28,2) +DEF_TEST(28,4) +DEF_TEST(28,8) +DEF_TEST(28,16) +DEF_TEST(29,1) +DEF_TEST(29,2) +DEF_TEST(29,4) +DEF_TEST(29,8) +DEF_TEST(29,16) +DEF_TEST(30,1) +DEF_TEST(30,2) +DEF_TEST(30,4) +DEF_TEST(30,8) +DEF_TEST(30,16) +DEF_TEST(31,1) +DEF_TEST(31,2) +DEF_TEST(31,4) +DEF_TEST(31,8) +DEF_TEST(31,16) +DEF_TEST(32,1) +DEF_TEST(32,2) +DEF_TEST(32,4) +DEF_TEST(32,8) +DEF_TEST(32,16) +DEF_TEST(33,1) +DEF_TEST(33,2) +DEF_TEST(33,4) +DEF_TEST(33,8) +DEF_TEST(33,16) +DEF_TEST(34,1) +DEF_TEST(34,2) +DEF_TEST(34,4) +DEF_TEST(34,8) +DEF_TEST(34,16) +DEF_TEST(35,1) +DEF_TEST(35,2) +DEF_TEST(35,4) +DEF_TEST(35,8) +DEF_TEST(35,16) +DEF_TEST(36,1) +DEF_TEST(36,2) +DEF_TEST(36,4) +DEF_TEST(36,8) +DEF_TEST(36,16) +DEF_TEST(37,1) +DEF_TEST(37,2) +DEF_TEST(37,4) +DEF_TEST(37,8) +DEF_TEST(37,16) +DEF_TEST(38,1) +DEF_TEST(38,2) +DEF_TEST(38,4) +DEF_TEST(38,8) +DEF_TEST(38,16) +DEF_TEST(39,1) +DEF_TEST(39,2) +DEF_TEST(39,4) +DEF_TEST(39,8) +DEF_TEST(39,16) +DEF_TEST(40,1) +DEF_TEST(40,2) +DEF_TEST(40,4) +DEF_TEST(40,8) +DEF_TEST(40,16) +DEF_TEST(41,1) +DEF_TEST(41,2) +DEF_TEST(41,4) +DEF_TEST(41,8) +DEF_TEST(41,16) +DEF_TEST(42,1) +DEF_TEST(42,2) +DEF_TEST(42,4) +DEF_TEST(42,8) +DEF_TEST(42,16) +DEF_TEST(43,1) +DEF_TEST(43,2) +DEF_TEST(43,4) +DEF_TEST(43,8) +DEF_TEST(43,16) +DEF_TEST(44,1) +DEF_TEST(44,2) +DEF_TEST(44,4) +DEF_TEST(44,8) +DEF_TEST(44,16) +DEF_TEST(45,1) +DEF_TEST(45,2) +DEF_TEST(45,4) +DEF_TEST(45,8) +DEF_TEST(45,16) +DEF_TEST(46,1) +DEF_TEST(46,2) +DEF_TEST(46,4) +DEF_TEST(46,8) +DEF_TEST(46,16) +DEF_TEST(47,1) +DEF_TEST(47,2) +DEF_TEST(47,4) +DEF_TEST(47,8) +DEF_TEST(47,16) +DEF_TEST(48,1) +DEF_TEST(48,2) +DEF_TEST(48,4) +DEF_TEST(48,8) +DEF_TEST(48,16) +DEF_TEST(49,1) +DEF_TEST(49,2) +DEF_TEST(49,4) +DEF_TEST(49,8) +DEF_TEST(49,16) +#else +DEF_TEST(3,1) +DEF_TEST(4,1) +DEF_TEST(4,2) +DEF_TEST(4,4) +DEF_TEST(5,1) +DEF_TEST(6,1) +DEF_TEST(7,1) +DEF_TEST(8,1) +DEF_TEST(8,2) +DEF_TEST(8,4) +DEF_TEST(8,8) +DEF_TEST(9,1) +DEF_TEST(16,1) +DEF_TEST(16,2) +DEF_TEST(16,4) +DEF_TEST(16,8) +DEF_TEST(16,16) +DEF_TEST(32,1) +DEF_TEST(32,2) +DEF_TEST(32,4) +DEF_TEST(32,8) +DEF_TEST(32,16) +#endif + +int +main(int argc, char **argv) +{ + +#ifdef TEST_ALL + RUN_TEST(1,1); + RUN_TEST(1,2); + RUN_TEST(1,4); + RUN_TEST(1,8); + RUN_TEST(1,16); + RUN_TEST(2,1); + RUN_TEST(2,2); + RUN_TEST(2,4); + RUN_TEST(2,8); + RUN_TEST(2,16); + RUN_TEST(3,1); + RUN_TEST(3,2); + RUN_TEST(3,4); + RUN_TEST(3,8); + RUN_TEST(3,16); + RUN_TEST(4,1); + RUN_TEST(4,2); + RUN_TEST(4,4); + RUN_TEST(4,8); + RUN_TEST(4,16); + RUN_TEST(5,1); + RUN_TEST(5,2); + RUN_TEST(5,4); + RUN_TEST(5,8); + RUN_TEST(5,16); + RUN_TEST(6,1); + RUN_TEST(6,2); + RUN_TEST(6,4); + RUN_TEST(6,8); + RUN_TEST(6,16); + RUN_TEST(7,1); + RUN_TEST(7,2); + RUN_TEST(7,4); + RUN_TEST(7,8); + RUN_TEST(7,16); + RUN_TEST(8,1); + RUN_TEST(8,2); + RUN_TEST(8,4); + RUN_TEST(8,8); + RUN_TEST(8,16); + RUN_TEST(9,1); + RUN_TEST(9,2); + RUN_TEST(9,4); + RUN_TEST(9,8); + RUN_TEST(9,16); + RUN_TEST(10,1); + RUN_TEST(10,2); + RUN_TEST(10,4); + RUN_TEST(10,8); + RUN_TEST(10,16); + RUN_TEST(11,1); + RUN_TEST(11,2); + RUN_TEST(11,4); + RUN_TEST(11,8); + RUN_TEST(11,16); + RUN_TEST(12,1); + RUN_TEST(12,2); + RUN_TEST(12,4); + RUN_TEST(12,8); + RUN_TEST(12,16); + RUN_TEST(13,1); + RUN_TEST(13,2); + RUN_TEST(13,4); + RUN_TEST(13,8); + RUN_TEST(13,16); + RUN_TEST(14,1); + RUN_TEST(14,2); + RUN_TEST(14,4); + RUN_TEST(14,8); + RUN_TEST(14,16); + RUN_TEST(15,1); + RUN_TEST(15,2); + RUN_TEST(15,4); + RUN_TEST(15,8); + RUN_TEST(15,16); + RUN_TEST(16,1); + RUN_TEST(16,2); + RUN_TEST(16,4); + RUN_TEST(16,8); + RUN_TEST(16,16); + RUN_TEST(17,1); + RUN_TEST(17,2); + RUN_TEST(17,4); + RUN_TEST(17,8); + RUN_TEST(17,16); + RUN_TEST(18,1); + RUN_TEST(18,2); + RUN_TEST(18,4); + RUN_TEST(18,8); + RUN_TEST(18,16); + RUN_TEST(19,1); + RUN_TEST(19,2); + RUN_TEST(19,4); + RUN_TEST(19,8); + RUN_TEST(19,16); + RUN_TEST(20,1); + RUN_TEST(20,2); + RUN_TEST(20,4); + RUN_TEST(20,8); + RUN_TEST(20,16); + RUN_TEST(21,1); + RUN_TEST(21,2); + RUN_TEST(21,4); + RUN_TEST(21,8); + RUN_TEST(21,16); + RUN_TEST(22,1); + RUN_TEST(22,2); + RUN_TEST(22,4); + RUN_TEST(22,8); + RUN_TEST(22,16); + RUN_TEST(23,1); + RUN_TEST(23,2); + RUN_TEST(23,4); + RUN_TEST(23,8); + RUN_TEST(23,16); + RUN_TEST(24,1); + RUN_TEST(24,2); + RUN_TEST(24,4); + RUN_TEST(24,8); + RUN_TEST(24,16); + RUN_TEST(25,1); + RUN_TEST(25,2); + RUN_TEST(25,4); + RUN_TEST(25,8); + RUN_TEST(25,16); + RUN_TEST(26,1); + RUN_TEST(26,2); + RUN_TEST(26,4); + RUN_TEST(26,8); + RUN_TEST(26,16); + RUN_TEST(27,1); + RUN_TEST(27,2); + RUN_TEST(27,4); + RUN_TEST(27,8); + RUN_TEST(27,16); + RUN_TEST(28,1); + RUN_TEST(28,2); + RUN_TEST(28,4); + RUN_TEST(28,8); + RUN_TEST(28,16); + RUN_TEST(29,1); + RUN_TEST(29,2); + RUN_TEST(29,4); + RUN_TEST(29,8); + RUN_TEST(29,16); + RUN_TEST(30,1); + RUN_TEST(30,2); + RUN_TEST(30,4); + RUN_TEST(30,8); + RUN_TEST(30,16); + RUN_TEST(31,1); + RUN_TEST(31,2); + RUN_TEST(31,4); + RUN_TEST(31,8); + RUN_TEST(31,16); + RUN_TEST(32,1); + RUN_TEST(32,2); + RUN_TEST(32,4); + RUN_TEST(32,8); + RUN_TEST(32,16); + RUN_TEST(33,1); + RUN_TEST(33,2); + RUN_TEST(33,4); + RUN_TEST(33,8); + RUN_TEST(33,16); + RUN_TEST(34,1); + RUN_TEST(34,2); + RUN_TEST(34,4); + RUN_TEST(34,8); + RUN_TEST(34,16); + RUN_TEST(35,1); + RUN_TEST(35,2); + RUN_TEST(35,4); + RUN_TEST(35,8); + RUN_TEST(35,16); + RUN_TEST(36,1); + RUN_TEST(36,2); + RUN_TEST(36,4); + RUN_TEST(36,8); + RUN_TEST(36,16); + RUN_TEST(37,1); + RUN_TEST(37,2); + RUN_TEST(37,4); + RUN_TEST(37,8); + RUN_TEST(37,16); + RUN_TEST(38,1); + RUN_TEST(38,2); + RUN_TEST(38,4); + RUN_TEST(38,8); + RUN_TEST(38,16); + RUN_TEST(39,1); + RUN_TEST(39,2); + RUN_TEST(39,4); + RUN_TEST(39,8); + RUN_TEST(39,16); + RUN_TEST(40,1); + RUN_TEST(40,2); + RUN_TEST(40,4); + RUN_TEST(40,8); + RUN_TEST(40,16); + RUN_TEST(41,1); + RUN_TEST(41,2); + RUN_TEST(41,4); + RUN_TEST(41,8); + RUN_TEST(41,16); + RUN_TEST(42,1); + RUN_TEST(42,2); + RUN_TEST(42,4); + RUN_TEST(42,8); + RUN_TEST(42,16); + RUN_TEST(43,1); + RUN_TEST(43,2); + RUN_TEST(43,4); + RUN_TEST(43,8); + RUN_TEST(43,16); + RUN_TEST(44,1); + RUN_TEST(44,2); + RUN_TEST(44,4); + RUN_TEST(44,8); + RUN_TEST(44,16); + RUN_TEST(45,1); + RUN_TEST(45,2); + RUN_TEST(45,4); + RUN_TEST(45,8); + RUN_TEST(45,16); + RUN_TEST(46,1); + RUN_TEST(46,2); + RUN_TEST(46,4); + RUN_TEST(46,8); + RUN_TEST(46,16); + RUN_TEST(47,1); + RUN_TEST(47,2); + RUN_TEST(47,4); + RUN_TEST(47,8); + RUN_TEST(47,16); + RUN_TEST(48,1); + RUN_TEST(48,2); + RUN_TEST(48,4); + RUN_TEST(48,8); + RUN_TEST(48,16); + RUN_TEST(49,1); + RUN_TEST(49,2); + RUN_TEST(49,4); + RUN_TEST(49,8); + RUN_TEST(49,16); +#else + RUN_TEST(3,1); + RUN_TEST(4,1); + RUN_TEST(4,2); + RUN_TEST(4,4); + RUN_TEST(5,1); + RUN_TEST(6,1); + RUN_TEST(7,1); + RUN_TEST(8,1); + RUN_TEST(8,2); + RUN_TEST(8,4); + RUN_TEST(8,8); + RUN_TEST(9,1); + RUN_TEST(16,1); + RUN_TEST(16,2); + RUN_TEST(16,4); + RUN_TEST(16,8); + RUN_TEST(16,16); + RUN_TEST(32,1); + RUN_TEST(32,2); + RUN_TEST(32,4); + RUN_TEST(32,8); + RUN_TEST(32,16); +#endif + + return 0; +} Index: gcc/testsuite/gcc.dg/strncmp-1.c =================================================================== --- gcc/testsuite/gcc.dg/strncmp-1.c (revision 0) +++ gcc/testsuite/gcc.dg/strncmp-1.c (working copy) @@ -0,0 +1,644 @@ +/* Test memcmp builtin expansion for compilation and proper execution. */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +#include +#include +#include + +#define RUN_TEST(SZ, ALIGN) test_strncmp_ ## SZ ## _ ## ALIGN () + +#define DEF_TEST(SZ, ALIGN) \ +static void test_strncmp_ ## SZ ## _ ## ALIGN (void) { \ + char one[3 * (SZ > 10 ? SZ : 10)]; \ + char two[3 * (SZ > 10 ? SZ : 10)]; \ + char three[8192] __attribute__ ((aligned (4096))); \ + char four[8192] __attribute__ ((aligned (4096))); \ + int i,j; \ + memset(one,0,sizeof(one)); \ + memset(two,0,sizeof(two)); \ + memset(three,0,sizeof(three)); \ + memset(four,0,sizeof(four)); \ + for (i = 0 ; i < SZ ; i++) \ + { \ + int r1; \ + char *a = one + (i & 1) * ALIGN; \ + char *b = two + (i & 1) * ALIGN; \ + memset(a, '-', SZ); \ + memset(b, '-', SZ); \ + a[i] = '1'; \ + b[i] = '2'; \ + a[SZ] = 0; \ + b[SZ] = 0; \ + if (!((r1 = strncmp (b, a, SZ)) > 0)) \ + { \ + printf("FAIL SZ %d ALIGN %d i=%d b > a r1=%d a='%s' b='%s'n", \ + SZ, ALIGN, i, r1, a, b); \ + abort (); \ + } \ + if (!((r1 = strncmp (a, b, SZ)) < 0)) \ + { \ + printf("FAIL SZ %d ALIGN %d i=%d a < b r1=%d a='%s' b='%s'n", \ + SZ, ALIGN, i, r1, a, b); \ + abort (); \ + } \ + b[i] = '1'; \ + if (!((r1 = strncmp (a, b, SZ)) == 0)) \ + { \ + printf("FAIL SZ %d ALIGN %d i=%d a == b r1=%d a='%s' b='%s'n", \ + SZ, ALIGN, i, r1, a, b); \ + abort (); \ + } \ + for(j = i; j < SZ ; j++) \ + { \ + a[j] = '1'; \ + b[j] = '2'; \ + } \ + if (!((r1 = strncmp(b, a, SZ)) > 0)) \ + { \ + printf("FAIL SZ %d ALIGN %d i=%d b > a r1=%d a='%s' b='%s'n", \ + SZ, ALIGN, i, r1, a, b); \ + abort (); \ + } \ + if (!((r1 = strncmp(a, b, SZ)) < 0)) \ + { \ + printf("FAIL SZ %d ALIGN %d i=%d a < b r1=%d a='%s' b='%s'n", \ + SZ, ALIGN, i, r1, a, b); \ + abort (); \ + } \ + a = three + 4096 - (SZ / 2 + (i & 1) * ALIGN); \ + b = four + 4096 - (SZ / 2 + (i & 1) * ALIGN); \ + memset(a, '-', SZ); \ + memset(b, '-', SZ); \ + a[i] = '1'; \ + b[i] = '2'; \ + a[SZ] = 0; \ + b[SZ] = 0; \ + if (!((r1 = strncmp(b, a, SZ)) > 0)) \ + { \ + printf("FAIL 4k SZ %d ALIGN %d i=%d b > a r1=%d a='%s' b='%s'n", \ + SZ, ALIGN, i, r1, a, b); \ + abort (); \ + } \ + if (!((r1 = strncmp(a, b, SZ)) < 0)) \ + { \ + printf("FAIL 4k SZ %d ALIGN %d i=%d a < b r1=%d a='%s' b='%s'n", \ + SZ, ALIGN, i, r1, a, b); \ + abort (); \ + } \ + b[i] = '1'; \ + if (!((r1 = strncmp(a, b, SZ)) == 0)) \ + { \ + printf("FAIL 4k SZ %d ALIGN %d i=%d a == b r1=%d a='%s' b='%s'n", \ + SZ, ALIGN, i, r1, a, b); \ + abort (); \ + } \ + } \ +} + +#ifdef TEST_ALL +DEF_TEST(1,1) +DEF_TEST(1,2) +DEF_TEST(1,4) +DEF_TEST(1,8) +DEF_TEST(1,16) +DEF_TEST(2,1) +DEF_TEST(2,2) +DEF_TEST(2,4) +DEF_TEST(2,8) +DEF_TEST(2,16) +DEF_TEST(3,1) +DEF_TEST(3,2) +DEF_TEST(3,4) +DEF_TEST(3,8) +DEF_TEST(3,16) +DEF_TEST(4,1) +DEF_TEST(4,2) +DEF_TEST(4,4) +DEF_TEST(4,8) +DEF_TEST(4,16) +DEF_TEST(5,1) +DEF_TEST(5,2) +DEF_TEST(5,4) +DEF_TEST(5,8) +DEF_TEST(5,16) +DEF_TEST(6,1) +DEF_TEST(6,2) +DEF_TEST(6,4) +DEF_TEST(6,8) +DEF_TEST(6,16) +DEF_TEST(7,1) +DEF_TEST(7,2) +DEF_TEST(7,4) +DEF_TEST(7,8) +DEF_TEST(7,16) +DEF_TEST(8,1) +DEF_TEST(8,2) +DEF_TEST(8,4) +DEF_TEST(8,8) +DEF_TEST(8,16) +DEF_TEST(9,1) +DEF_TEST(9,2) +DEF_TEST(9,4) +DEF_TEST(9,8) +DEF_TEST(9,16) +DEF_TEST(10,1) +DEF_TEST(10,2) +DEF_TEST(10,4) +DEF_TEST(10,8) +DEF_TEST(10,16) +DEF_TEST(11,1) +DEF_TEST(11,2) +DEF_TEST(11,4) +DEF_TEST(11,8) +DEF_TEST(11,16) +DEF_TEST(12,1) +DEF_TEST(12,2) +DEF_TEST(12,4) +DEF_TEST(12,8) +DEF_TEST(12,16) +DEF_TEST(13,1) +DEF_TEST(13,2) +DEF_TEST(13,4) +DEF_TEST(13,8) +DEF_TEST(13,16) +DEF_TEST(14,1) +DEF_TEST(14,2) +DEF_TEST(14,4) +DEF_TEST(14,8) +DEF_TEST(14,16) +DEF_TEST(15,1) +DEF_TEST(15,2) +DEF_TEST(15,4) +DEF_TEST(15,8) +DEF_TEST(15,16) +DEF_TEST(16,1) +DEF_TEST(16,2) +DEF_TEST(16,4) +DEF_TEST(16,8) +DEF_TEST(16,16) +DEF_TEST(17,1) +DEF_TEST(17,2) +DEF_TEST(17,4) +DEF_TEST(17,8) +DEF_TEST(17,16) +DEF_TEST(18,1) +DEF_TEST(18,2) +DEF_TEST(18,4) +DEF_TEST(18,8) +DEF_TEST(18,16) +DEF_TEST(19,1) +DEF_TEST(19,2) +DEF_TEST(19,4) +DEF_TEST(19,8) +DEF_TEST(19,16) +DEF_TEST(20,1) +DEF_TEST(20,2) +DEF_TEST(20,4) +DEF_TEST(20,8) +DEF_TEST(20,16) +DEF_TEST(21,1) +DEF_TEST(21,2) +DEF_TEST(21,4) +DEF_TEST(21,8) +DEF_TEST(21,16) +DEF_TEST(22,1) +DEF_TEST(22,2) +DEF_TEST(22,4) +DEF_TEST(22,8) +DEF_TEST(22,16) +DEF_TEST(23,1) +DEF_TEST(23,2) +DEF_TEST(23,4) +DEF_TEST(23,8) +DEF_TEST(23,16) +DEF_TEST(24,1) +DEF_TEST(24,2) +DEF_TEST(24,4) +DEF_TEST(24,8) +DEF_TEST(24,16) +DEF_TEST(25,1) +DEF_TEST(25,2) +DEF_TEST(25,4) +DEF_TEST(25,8) +DEF_TEST(25,16) +DEF_TEST(26,1) +DEF_TEST(26,2) +DEF_TEST(26,4) +DEF_TEST(26,8) +DEF_TEST(26,16) +DEF_TEST(27,1) +DEF_TEST(27,2) +DEF_TEST(27,4) +DEF_TEST(27,8) +DEF_TEST(27,16) +DEF_TEST(28,1) +DEF_TEST(28,2) +DEF_TEST(28,4) +DEF_TEST(28,8) +DEF_TEST(28,16) +DEF_TEST(29,1) +DEF_TEST(29,2) +DEF_TEST(29,4) +DEF_TEST(29,8) +DEF_TEST(29,16) +DEF_TEST(30,1) +DEF_TEST(30,2) +DEF_TEST(30,4) +DEF_TEST(30,8) +DEF_TEST(30,16) +DEF_TEST(31,1) +DEF_TEST(31,2) +DEF_TEST(31,4) +DEF_TEST(31,8) +DEF_TEST(31,16) +DEF_TEST(32,1) +DEF_TEST(32,2) +DEF_TEST(32,4) +DEF_TEST(32,8) +DEF_TEST(32,16) +DEF_TEST(33,1) +DEF_TEST(33,2) +DEF_TEST(33,4) +DEF_TEST(33,8) +DEF_TEST(33,16) +DEF_TEST(34,1) +DEF_TEST(34,2) +DEF_TEST(34,4) +DEF_TEST(34,8) +DEF_TEST(34,16) +DEF_TEST(35,1) +DEF_TEST(35,2) +DEF_TEST(35,4) +DEF_TEST(35,8) +DEF_TEST(35,16) +DEF_TEST(36,1) +DEF_TEST(36,2) +DEF_TEST(36,4) +DEF_TEST(36,8) +DEF_TEST(36,16) +DEF_TEST(37,1) +DEF_TEST(37,2) +DEF_TEST(37,4) +DEF_TEST(37,8) +DEF_TEST(37,16) +DEF_TEST(38,1) +DEF_TEST(38,2) +DEF_TEST(38,4) +DEF_TEST(38,8) +DEF_TEST(38,16) +DEF_TEST(39,1) +DEF_TEST(39,2) +DEF_TEST(39,4) +DEF_TEST(39,8) +DEF_TEST(39,16) +DEF_TEST(40,1) +DEF_TEST(40,2) +DEF_TEST(40,4) +DEF_TEST(40,8) +DEF_TEST(40,16) +DEF_TEST(41,1) +DEF_TEST(41,2) +DEF_TEST(41,4) +DEF_TEST(41,8) +DEF_TEST(41,16) +DEF_TEST(42,1) +DEF_TEST(42,2) +DEF_TEST(42,4) +DEF_TEST(42,8) +DEF_TEST(42,16) +DEF_TEST(43,1) +DEF_TEST(43,2) +DEF_TEST(43,4) +DEF_TEST(43,8) +DEF_TEST(43,16) +DEF_TEST(44,1) +DEF_TEST(44,2) +DEF_TEST(44,4) +DEF_TEST(44,8) +DEF_TEST(44,16) +DEF_TEST(45,1) +DEF_TEST(45,2) +DEF_TEST(45,4) +DEF_TEST(45,8) +DEF_TEST(45,16) +DEF_TEST(46,1) +DEF_TEST(46,2) +DEF_TEST(46,4) +DEF_TEST(46,8) +DEF_TEST(46,16) +DEF_TEST(47,1) +DEF_TEST(47,2) +DEF_TEST(47,4) +DEF_TEST(47,8) +DEF_TEST(47,16) +DEF_TEST(48,1) +DEF_TEST(48,2) +DEF_TEST(48,4) +DEF_TEST(48,8) +DEF_TEST(48,16) +DEF_TEST(49,1) +DEF_TEST(49,2) +DEF_TEST(49,4) +DEF_TEST(49,8) +DEF_TEST(49,16) +#else +DEF_TEST(3,1) +DEF_TEST(4,1) +DEF_TEST(4,2) +DEF_TEST(4,4) +DEF_TEST(5,1) +DEF_TEST(6,1) +DEF_TEST(7,1) +DEF_TEST(8,1) +DEF_TEST(8,2) +DEF_TEST(8,4) +DEF_TEST(8,8) +DEF_TEST(9,1) +DEF_TEST(16,1) +DEF_TEST(16,2) +DEF_TEST(16,4) +DEF_TEST(16,8) +DEF_TEST(16,16) +DEF_TEST(32,1) +DEF_TEST(32,2) +DEF_TEST(32,4) +DEF_TEST(32,8) +DEF_TEST(32,16) +#endif + +int +main(int argc, char **argv) +{ + +#ifdef TEST_ALL + RUN_TEST(1,1); + RUN_TEST(1,2); + RUN_TEST(1,4); + RUN_TEST(1,8); + RUN_TEST(1,16); + RUN_TEST(2,1); + RUN_TEST(2,2); + RUN_TEST(2,4); + RUN_TEST(2,8); + RUN_TEST(2,16); + RUN_TEST(3,1); + RUN_TEST(3,2); + RUN_TEST(3,4); + RUN_TEST(3,8); + RUN_TEST(3,16); + RUN_TEST(4,1); + RUN_TEST(4,2); + RUN_TEST(4,4); + RUN_TEST(4,8); + RUN_TEST(4,16); + RUN_TEST(5,1); + RUN_TEST(5,2); + RUN_TEST(5,4); + RUN_TEST(5,8); + RUN_TEST(5,16); + RUN_TEST(6,1); + RUN_TEST(6,2); + RUN_TEST(6,4); + RUN_TEST(6,8); + RUN_TEST(6,16); + RUN_TEST(7,1); + RUN_TEST(7,2); + RUN_TEST(7,4); + RUN_TEST(7,8); + RUN_TEST(7,16); + RUN_TEST(8,1); + RUN_TEST(8,2); + RUN_TEST(8,4); + RUN_TEST(8,8); + RUN_TEST(8,16); + RUN_TEST(9,1); + RUN_TEST(9,2); + RUN_TEST(9,4); + RUN_TEST(9,8); + RUN_TEST(9,16); + RUN_TEST(10,1); + RUN_TEST(10,2); + RUN_TEST(10,4); + RUN_TEST(10,8); + RUN_TEST(10,16); + RUN_TEST(11,1); + RUN_TEST(11,2); + RUN_TEST(11,4); + RUN_TEST(11,8); + RUN_TEST(11,16); + RUN_TEST(12,1); + RUN_TEST(12,2); + RUN_TEST(12,4); + RUN_TEST(12,8); + RUN_TEST(12,16); + RUN_TEST(13,1); + RUN_TEST(13,2); + RUN_TEST(13,4); + RUN_TEST(13,8); + RUN_TEST(13,16); + RUN_TEST(14,1); + RUN_TEST(14,2); + RUN_TEST(14,4); + RUN_TEST(14,8); + RUN_TEST(14,16); + RUN_TEST(15,1); + RUN_TEST(15,2); + RUN_TEST(15,4); + RUN_TEST(15,8); + RUN_TEST(15,16); + RUN_TEST(16,1); + RUN_TEST(16,2); + RUN_TEST(16,4); + RUN_TEST(16,8); + RUN_TEST(16,16); + RUN_TEST(17,1); + RUN_TEST(17,2); + RUN_TEST(17,4); + RUN_TEST(17,8); + RUN_TEST(17,16); + RUN_TEST(18,1); + RUN_TEST(18,2); + RUN_TEST(18,4); + RUN_TEST(18,8); + RUN_TEST(18,16); + RUN_TEST(19,1); + RUN_TEST(19,2); + RUN_TEST(19,4); + RUN_TEST(19,8); + RUN_TEST(19,16); + RUN_TEST(20,1); + RUN_TEST(20,2); + RUN_TEST(20,4); + RUN_TEST(20,8); + RUN_TEST(20,16); + RUN_TEST(21,1); + RUN_TEST(21,2); + RUN_TEST(21,4); + RUN_TEST(21,8); + RUN_TEST(21,16); + RUN_TEST(22,1); + RUN_TEST(22,2); + RUN_TEST(22,4); + RUN_TEST(22,8); + RUN_TEST(22,16); + RUN_TEST(23,1); + RUN_TEST(23,2); + RUN_TEST(23,4); + RUN_TEST(23,8); + RUN_TEST(23,16); + RUN_TEST(24,1); + RUN_TEST(24,2); + RUN_TEST(24,4); + RUN_TEST(24,8); + RUN_TEST(24,16); + RUN_TEST(25,1); + RUN_TEST(25,2); + RUN_TEST(25,4); + RUN_TEST(25,8); + RUN_TEST(25,16); + RUN_TEST(26,1); + RUN_TEST(26,2); + RUN_TEST(26,4); + RUN_TEST(26,8); + RUN_TEST(26,16); + RUN_TEST(27,1); + RUN_TEST(27,2); + RUN_TEST(27,4); + RUN_TEST(27,8); + RUN_TEST(27,16); + RUN_TEST(28,1); + RUN_TEST(28,2); + RUN_TEST(28,4); + RUN_TEST(28,8); + RUN_TEST(28,16); + RUN_TEST(29,1); + RUN_TEST(29,2); + RUN_TEST(29,4); + RUN_TEST(29,8); + RUN_TEST(29,16); + RUN_TEST(30,1); + RUN_TEST(30,2); + RUN_TEST(30,4); + RUN_TEST(30,8); + RUN_TEST(30,16); + RUN_TEST(31,1); + RUN_TEST(31,2); + RUN_TEST(31,4); + RUN_TEST(31,8); + RUN_TEST(31,16); + RUN_TEST(32,1); + RUN_TEST(32,2); + RUN_TEST(32,4); + RUN_TEST(32,8); + RUN_TEST(32,16); + RUN_TEST(33,1); + RUN_TEST(33,2); + RUN_TEST(33,4); + RUN_TEST(33,8); + RUN_TEST(33,16); + RUN_TEST(34,1); + RUN_TEST(34,2); + RUN_TEST(34,4); + RUN_TEST(34,8); + RUN_TEST(34,16); + RUN_TEST(35,1); + RUN_TEST(35,2); + RUN_TEST(35,4); + RUN_TEST(35,8); + RUN_TEST(35,16); + RUN_TEST(36,1); + RUN_TEST(36,2); + RUN_TEST(36,4); + RUN_TEST(36,8); + RUN_TEST(36,16); + RUN_TEST(37,1); + RUN_TEST(37,2); + RUN_TEST(37,4); + RUN_TEST(37,8); + RUN_TEST(37,16); + RUN_TEST(38,1); + RUN_TEST(38,2); + RUN_TEST(38,4); + RUN_TEST(38,8); + RUN_TEST(38,16); + RUN_TEST(39,1); + RUN_TEST(39,2); + RUN_TEST(39,4); + RUN_TEST(39,8); + RUN_TEST(39,16); + RUN_TEST(40,1); + RUN_TEST(40,2); + RUN_TEST(40,4); + RUN_TEST(40,8); + RUN_TEST(40,16); + RUN_TEST(41,1); + RUN_TEST(41,2); + RUN_TEST(41,4); + RUN_TEST(41,8); + RUN_TEST(41,16); + RUN_TEST(42,1); + RUN_TEST(42,2); + RUN_TEST(42,4); + RUN_TEST(42,8); + RUN_TEST(42,16); + RUN_TEST(43,1); + RUN_TEST(43,2); + RUN_TEST(43,4); + RUN_TEST(43,8); + RUN_TEST(43,16); + RUN_TEST(44,1); + RUN_TEST(44,2); + RUN_TEST(44,4); + RUN_TEST(44,8); + RUN_TEST(44,16); + RUN_TEST(45,1); + RUN_TEST(45,2); + RUN_TEST(45,4); + RUN_TEST(45,8); + RUN_TEST(45,16); + RUN_TEST(46,1); + RUN_TEST(46,2); + RUN_TEST(46,4); + RUN_TEST(46,8); + RUN_TEST(46,16); + RUN_TEST(47,1); + RUN_TEST(47,2); + RUN_TEST(47,4); + RUN_TEST(47,8); + RUN_TEST(47,16); + RUN_TEST(48,1); + RUN_TEST(48,2); + RUN_TEST(48,4); + RUN_TEST(48,8); + RUN_TEST(48,16); + RUN_TEST(49,1); + RUN_TEST(49,2); + RUN_TEST(49,4); + RUN_TEST(49,8); + RUN_TEST(49,16); +#else + RUN_TEST(3,1); + RUN_TEST(4,1); + RUN_TEST(4,2); + RUN_TEST(4,4); + RUN_TEST(5,1); + RUN_TEST(6,1); + RUN_TEST(7,1); + RUN_TEST(8,1); + RUN_TEST(8,2); + RUN_TEST(8,4); + RUN_TEST(8,8); + RUN_TEST(9,1); + RUN_TEST(16,1); + RUN_TEST(16,2); + RUN_TEST(16,4); + RUN_TEST(16,8); + RUN_TEST(16,16); + RUN_TEST(32,1); + RUN_TEST(32,2); + RUN_TEST(32,4); + RUN_TEST(32,8); + RUN_TEST(32,16); +#endif + return 0; +}