From patchwork Mon Dec 12 12:11:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 18385 Received: (qmail 14511 invoked by alias); 12 Dec 2016 12:11:46 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 14497 invoked by uid 89); 12 Dec 2016 12:11:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=HAccept-Language:en-GB X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com From: Wilco Dijkstra To: "libc-alpha@sourceware.org" CC: nd Subject: [GLIBC][PATCH] Remove strcmp inlines Date: Mon, 12 Dec 2016 12:11:32 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-office365-filtering-correlation-id: 6e930e6c-9ad4-4443-124a-08d4228802ee x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:AM5PR0802MB2610; x-microsoft-exchange-diagnostics: 1; AM5PR0802MB2610; 7:s5aGIw7db8rvHB5++VmXzh0MsqnMP7kr5+9b8/sMC+BGkEwPapkfGtLQmuKdfxzWOxSC6OdUIkuTkDbROFG45qduLvxPMUHcNijNU7BrZ3VgLwuHiXhPKfGWfV4zqTfrMgeKWWdizvVV2RyCPpArp3M4BSq9X3bdQ5MnwLQCvFIn0JHPc7jHxu9/cfvcRGsbRxW4ZszxshRcct+kHHyS+KnAmN1D/87xhxS9IrO9Mv0ZOJEGQRCdX08iaskqCAd0oKAuKYAiWX7ylB2C8oZHDA1E83IGq7DlVNFrBg+yTOFKxW3W+i2sAVV+0BcSHs+ldDWKnwmwfEFDNNxoYlHynWsH83KgNWdDEze+cCT7Lw1wEQUED1Qx4A0gktSY/uG1uAXpsSJz9udaDSp2tSQcfY69JKBuNIjTzNMen+w57+JvaDw+XqfURDpFUHTnan1nh7dUKwnnsCWSfG3G4NJ5Pw== nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(20161123560025)(20161123558021)(20161123555025)(20161123564025)(6072148); SRVR:AM5PR0802MB2610; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0802MB2610; x-forefront-prvs: 0154C61618 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39840400002)(39410400002)(39850400002)(39450400003)(54534003)(199003)(377424004)(189002)(86362001)(575784001)(5660300001)(74316002)(450100001)(101416001)(3846002)(6436002)(110136003)(122556002)(50986999)(38730400001)(102836003)(189998001)(7696004)(77096006)(66066001)(6116002)(6916009)(54356999)(4001150100001)(68736007)(6506006)(5640700002)(2900100001)(2906002)(305945005)(97736004)(7736002)(92566002)(3660700001)(9686002)(106116001)(106356001)(33656002)(8936002)(2501003)(3280700002)(8676002)(105586002)(4326007)(76576001)(81156014)(81166006)(2351001)(40753002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0802MB2610; H:AM5PR0802MB2610.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Dec 2016 12:11:32.3013 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2610 Remove the str(n)cmp inlines from string/bits/string2.h. The strncmp optimization seems unlikely to ever be useful, but if it occurs in real code it should be added to GCC. Expanding strcmp of small strings does appear useful (benchmarking shows it is 2-3x faster), so this would be useful to implement in GCC. ChangeLog: 2015-12-12 Wilco Dijkstra * string/bits/string2.h (strcmp): Remove define. (__strcmp_cg): Likewise. (strncmp): Likewise. diff --git a/string/bits/string2.h b/string/bits/string2.h index b0be5f6a49024a0bedfc37e9ec2c0356e0e4fa09..5e0339223697256fff7eba4cc32d2eb618f07713 100644 --- a/string/bits/string2.h +++ b/string/bits/string2.h @@ -60,64 +60,6 @@ # define __stpcpy(dest, src) __builtin_stpcpy (dest, src) #endif -/* Compare characters of S1 and S2. */ -#ifndef strcmp -# define strcmp(s1, s2) \ - __extension__ \ - ({ size_t __s1_len, __s2_len; \ - (__builtin_constant_p (s1) && __builtin_constant_p (s2) \ - && (__s1_len = strlen (s1), __s2_len = strlen (s2), \ - (!__string2_1bptr_p (s1) || __s1_len >= 4) \ - && (!__string2_1bptr_p (s2) || __s2_len >= 4)) \ - ? __builtin_strcmp (s1, s2) \ - : (__builtin_constant_p (s1) && __string2_1bptr_p (s1) \ - && (__s1_len = strlen (s1), __s1_len < 4) \ - ? (__builtin_constant_p (s2) && __string2_1bptr_p (s2) \ - ? __builtin_strcmp (s1, s2) \ - : __strcmp_cg (s1, s2, __s1_len)) \ - : (__builtin_constant_p (s2) && __string2_1bptr_p (s2) \ - && (__s2_len = strlen (s2), __s2_len < 4) \ - ? (__builtin_constant_p (s1) && __string2_1bptr_p (s1) \ - ? __builtin_strcmp (s1, s2) \ - : -__strcmp_cg (s2, s1, __s2_len)) \ - : __builtin_strcmp (s1, s2)))); }) - -# define __strcmp_cg(s1, s2, l1) \ - (__extension__ ({ const unsigned char *__s2 = \ - (const unsigned char *) (const char *) (s2); \ - int __result = \ - (((const unsigned char *) (const char *) (s1))[0] \ - - __s2[0]); \ - if (l1 > 0 && __result == 0) \ - { \ - __result = (((const unsigned char *) \ - (const char *) (s1))[1] - __s2[1]); \ - if (l1 > 1 && __result == 0) \ - { \ - __result = (((const unsigned char *) \ - (const char *) (s1))[2] - __s2[2]); \ - if (l1 > 2 && __result == 0) \ - __result = (((const unsigned char *) \ - (const char *) (s1))[3] \ - - __s2[3]); \ - } \ - } \ - __result; })) -#endif - - -/* Compare N characters of S1 and S2. */ -#ifndef strncmp -# define strncmp(s1, s2, n) \ - (__extension__ (__builtin_constant_p (n) \ - && ((__builtin_constant_p (s1) \ - && strlen (s1) < ((size_t) (n))) \ - || (__builtin_constant_p (s2) \ - && strlen (s2) < ((size_t) (n)))) \ - ? strcmp (s1, s2) : strncmp (s1, s2, n))) -#endif - - #ifndef _FORCE_INLINES # undef __STRING_INLINE #endif