Re: [RFCv2] string: Use faster alternatives when constant arguments are used

2019-04-02 Thread Rasmus Villemoes
On 02/04/2019 01.55, Sultan Alsawaf wrote: > On Mon, Apr 01, 2019 at 10:43:13PM +0200, Rasmus Villemoes wrote: >> No. First, these are concerns for all arches. Second, if you can find >> some particular place where string parsing/matching is in any way >> performance relevant and not just done

Re: [RFCv2] string: Use faster alternatives when constant arguments are used

2019-04-01 Thread Sultan Alsawaf
On Mon, Apr 01, 2019 at 10:43:13PM +0200, Rasmus Villemoes wrote: > Consider your patch replacing !strcmp(buf, "123") by !memcmp(buf, "123", > 4). buf is known to point to a nul-terminated string. But it may point > at, say, the second-last byte in a page, with the last byte in that page > being a

Re: [RFCv2] string: Use faster alternatives when constant arguments are used

2019-04-01 Thread Rasmus Villemoes
On 30/03/2019 23.59, Sultan Alsawaf wrote: > How can the memcmps cross a page boundary when memcmp itself will > only read in large buffers of data at word boundaries? Consider your patch replacing !strcmp(buf, "123") by !memcmp(buf, "123", 4). buf is known to point to a nul-terminated string.

Re: [RFCv2] string: Use faster alternatives when constant arguments are used

2019-03-30 Thread Sultan Alsawaf
On Mon, Mar 25, 2019 at 10:24:00PM +0100, Rasmus Villemoes wrote: > What I'm worried about is your patch changing every single strcmp(, > "literal") into a memcmp, with absolutely no way of knowing or checking > anything about the other buffer. And actually, it doesn't have to be a > BE arch with

Re: [RFCv2] string: Use faster alternatives when constant arguments are used

2019-03-25 Thread Rasmus Villemoes
On 24/03/2019 23.32, Sultan Alsawaf wrote: > On Sun, Mar 24, 2019 at 10:17:49PM +0100, Rasmus Villemoes wrote: >> gcc already knows the semantics of these functions and can optimize >> accordingly. E.g. for strcpy() of a literal to a buffer, gcc readily >> compiles > > The example you gave

Re: [RFCv2] string: Use faster alternatives when constant arguments are used

2019-03-24 Thread Sultan Alsawaf
On Sun, Mar 24, 2019 at 10:17:49PM +0100, Rasmus Villemoes wrote: > gcc already knows the semantics of these functions and can optimize > accordingly. E.g. for strcpy() of a literal to a buffer, gcc readily > compiles The example you gave appears to get optimized accordingly, but there are

Re: [RFCv2] string: Use faster alternatives when constant arguments are used

2019-03-24 Thread Rasmus Villemoes
On 24/03/2019 03.24, Sultan Alsawaf wrote: > I messed up the return value for strcat in the first patch. Here's a fixed > version, ready for some scathing reviews. > > From: Sultan Alsawaf > > When strcpy, strcat, and strcmp are used with a literal string, they can > be optimized to memcpy or

Re: [RFCv2] string: Use faster alternatives when constant arguments are used

2019-03-23 Thread Nathan Chancellor
On Sat, Mar 23, 2019 at 07:24:06PM -0700, Sultan Alsawaf wrote: > I messed up the return value for strcat in the first patch. Here's a fixed > version, ready for some scathing reviews. > > From: Sultan Alsawaf > > When strcpy, strcat, and strcmp are used with a literal string, they can > be

[RFCv2] string: Use faster alternatives when constant arguments are used

2019-03-23 Thread Sultan Alsawaf
I messed up the return value for strcat in the first patch. Here's a fixed version, ready for some scathing reviews. From: Sultan Alsawaf When strcpy, strcat, and strcmp are used with a literal string, they can be optimized to memcpy or memcmp calls. These alternatives are faster since knowing