lkml.org 
[lkml]   [2015]   [Jun]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] small update for strlen, strnlen, use less cpu instructions
From
> Now strlen() increments a variable for each character it faces,
> hence it will consume more cycles.

It doesn't matter if there is a dependency in a loop:

Before:
520: 48 83 c0 01 add $0x1,%rax
524: 80 38 00 cmpb $0x0,(%rax)
527: 75 f7 jne 520

After:
500: 48 83 c0 01 add $0x1,%rax
504: 80 3c 07 00 cmpb $0x0,(%rdi,%rax,1)
508: 75 f6 jne 500


\
 
 \ /
  Last update: 2015-06-16 14:01    [W:0.040 / U:0.968 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site