From patchwork Tue Mar 7 15:32:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 19459 Received: (qmail 43884 invoked by alias); 7 Mar 2017 15:32:36 -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 43851 invoked by uid 89); 7 Mar 2017 15:32:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=HContent-Language:en-GB X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com From: Wilco Dijkstra To: "libc-alpha@sourceware.org" CC: nd Subject: Re: [GLIBC][PATCH] Remove strcmp inlines Date: Tue, 7 Mar 2017 15:32:30 +0000 Message-ID: References: , In-Reply-To: authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; x-ms-office365-filtering-correlation-id: 2f14e9de-bb59-4e5b-a760-08d4656f2b26 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:VI1PR0802MB2622; x-microsoft-exchange-diagnostics: 1; VI1PR0802MB2622; 7:U+GlWFtrth+RP6P7JhC3qawWupFIeUAtODzuBBsArE+izDW4nxaX71QwjCNSpp1ZeQyGB1ZZkUOVk5mvJlTI61VGTwliPMdWZYxr56aK/x8etjJe2nf1HzLr4dTC9OdeyDPljDzh6t/yB1Tr0L4MP8Vcom/VZb3ushS7+hHgHXfzOzqyPbQz2p6/q4oRrXrzVidRsK/Mh0tWRd53VcMtYXlFkvliH7YH9Un82aZJIS3zx0AuctrjEEbvy0RycL0vnTc41qnTcmHV7mE4R6ppQcJBwICL3BbdTfmd/WUCZWFnowMOm+xoxjBXqwO9Mhg1Qlb8m/dKGoZvEg2Ynd+97g== 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)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123564025)(20161123562025)(20161123558025)(20161123560025)(6072148); SRVR:VI1PR0802MB2622; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0802MB2622; x-forefront-prvs: 0239D46DB6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39410400002)(39850400002)(39860400002)(39840400002)(39450400003)(377424004)(54534003)(53936002)(33656002)(3660700001)(189998001)(6916009)(55016002)(4001150100001)(6246003)(6436002)(2501003)(99286003)(25786008)(86362001)(2950100002)(5640700003)(575784001)(6506006)(2900100001)(5660300001)(77096006)(7696004)(9686003)(50986999)(81166006)(106116001)(3280700002)(2351001)(76176999)(8676002)(74316002)(110136004)(54356999)(7736002)(38730400002)(8936002)(4326008)(66066001)(2906002)(450100001)(102836003)(122556002)(3846002)(6116002)(305945005)(229853002)(40753002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0802MB2622; H:VI1PR0802MB2621.eurprd08.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Mar 2017 15:32:30.3058 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2622 ping     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 (PR 78809). 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