From patchwork Wed Nov 16 18:59:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 17524 Received: (qmail 71906 invoked by alias); 16 Nov 2016 18:59:51 -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 71893 invoked by uid 89); 16 Nov 2016 18:59:50 -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 autolearn=ham version=3.3.2 spammy=Hx-languages-length:1119 X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com From: Wilco Dijkstra To: "libc-alpha@sourceware.org" CC: nd Subject: [PATCH] Do not transform strchr into rawmemchr Date: Wed, 16 Nov 2016 18:59:36 +0000 Message-ID: References: In-Reply-To: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-microsoft-exchange-diagnostics: 1; AM5PR0802MB2611; 7:SiqPqNBHpwpiLVWURCfN7TGh5fS652mskQIVBXMfyE3xlA3LdMSjmkB63DBuTN94HMf60/O39y+yT23qyUouMbFftqMsFA+RaozRTwRUWzyccEjnFphMk6s97iUD9bj8RMLibFEe3MFw2kDXxk2dsPtI5/oYe4e9DPzH7ixVOJXDlstGBgdB0/6nY8dcaoFZm3BI18ose53QnhC3OzAADEmDre4tHitcyVepTKG7LlKgjVR268reMEcsX/saq2EVc5a9hIn0eVLaKX+p/TGs6/30XuVm97lR8IftxIqrorOMkh1F1O5V/f9/AlP+1R1WIRmP3fYSMjcJZznEKQ/YRNNMajHdTVtQDroOlllFrSs= x-ms-office365-filtering-correlation-id: f1aab429-670c-4963-5b2d-08d40e52b5f6 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:AM5PR0802MB2611; nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6060326)(6040281)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6061324)(6041223); SRVR:AM5PR0802MB2611; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0802MB2611; x-forefront-prvs: 01283822F8 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(189002)(54534003)(377424004)(199003)(8936002)(81166006)(81156014)(575784001)(77096005)(2351001)(2501003)(450100001)(4326007)(6506003)(189998001)(86362001)(5660300001)(2906002)(5640700001)(2950100002)(76576001)(122556002)(3660700001)(68736007)(87936001)(50986999)(8676002)(101416001)(110136003)(7696004)(3846002)(92566002)(76176999)(6916009)(2900100001)(3280700002)(54356999)(4001150100001)(106356001)(102836003)(33656002)(66066001)(105586002)(106116001)(7736002)(7846002)(305945005)(6116002)(74316002)(97736004)(9686002)(40753002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0802MB2611; H:AM5PR0802MB2610.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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: 16 Nov 2016 18:59:36.6298 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2611 GLIBC uses strchr (s, '\0') as an idiom to find the end of a string. This is transformed into rawmemchr by the bits/string2.h header. However this is generally slower than strlen on most targets, even when an optimized rawmemchr implementation exists.  Since GCC7 optimizes strchr (s, '\0') to strlen (s) + s, the GLIBC headers should not transform this to rawmemchr. GLIBC tests pass, OK for commit? ChangeLog: 2015-11-16  Wilco Dijkstra          * string/bits/string2.h (strchr): Use __builtin_strchr. diff --git a/string/bits/string2.h b/string/bits/string2.h index 80987602f34ded483854bcea86dabd5b81e42a18..f0e2ce9cd87033698236e7878c63a2e5f9bb1887 100644 --- a/string/bits/string2.h +++ b/string/bits/string2.h @@ -59,12 +59,7 @@      #ifndef _HAVE_STRING_ARCH_strchr -extern void *__rawmemchr (const void *__s, int __c); -#  define strchr(s, c) \ -  (__extension__ (__builtin_constant_p (c) && !__builtin_constant_p (s)              \ -                 && (c) == '\0'                                       \ -                 ? (char *) __rawmemchr (s, c)                                \ -                 : __builtin_strchr (s, c))) +# define strchr(s, c) __builtin_strchr (s, c)  #endif