From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754419AbbFPLnz (ORCPT ); Tue, 16 Jun 2015 07:43:55 -0400 Received: from a.ns.miles-group.at ([95.130.255.143]:65275 "EHLO radon.swed.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751486AbbFPLnq (ORCPT ); Tue, 16 Jun 2015 07:43:46 -0400 Message-ID: <55800BEF.7000301@nod.at> Date: Tue, 16 Jun 2015 13:43:43 +0200 From: Richard Weinberger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Alexey Dobriyan CC: lukes357@gmail.com, Linux Kernel Subject: Re: [PATCH] small update for strlen, strnlen, use less cpu instructions References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 16.06.2015 um 13:41 schrieb Alexey Dobriyan: >> 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 > Hmmm. Thanks for pointing this out! Thanks, //richard