Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753237AbbBEThE (ORCPT ); Thu, 5 Feb 2015 14:37:04 -0500 Received: from mail-ig0-f177.google.com ([209.85.213.177]:42344 "EHLO mail-ig0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752191AbbBEThB (ORCPT ); Thu, 5 Feb 2015 14:37:01 -0500 MIME-Version: 1.0 In-Reply-To: References: <1422897162-111998-1-git-send-email-aksgarg1989@gmail.com> <1422938843.2293.4.camel@stgolabs.net> Date: Thu, 5 Feb 2015 11:37:00 -0800 X-Google-Sender-Auth: gtVdkcMdxGoJ9xzZAKxj3_P3Zeg Message-ID: Subject: Re: [PATCH] lib/int_sqrt.c: Optimize square root function From: Linus Torvalds To: Anshul Garg Cc: Davidlohr Bueso , Linux Kernel Mailing List , "anshul.g@samsung.com" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1222 Lines: 26 On Thu, Feb 5, 2015 at 10:43 AM, Anshul Garg wrote: > > NOTE :: > I have not used gcc optimizations while compilation. > With O2 level optimization proposed solution is taking more time. The thing is, the kernel is compiled with -O2, so that's what matters. Also, for very tight loops like this, the major costs tend to be very subtle microarchitectural details, particularly branch prediction. Which in turn end up sometimes depending on just exactly where the branches were placed, and even whether two conditional branches were in the same 8-byte aligned region etc things (because the branch prediction might be done ignoring the low bits of the EIP etc). So not only does the exact microarchitecture matter, things that don't *seem* like they should matter can change behavior a lot. My point is really that the performance numbers are very ambiguous. The patch may well help in some situations, but hurt in others. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/