From owner-svn-src-all@FreeBSD.ORG Thu Feb 28 17:37:40 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 24107D70; Thu, 28 Feb 2013 17:37:40 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-la0-x236.google.com (mail-la0-x236.google.com [IPv6:2a00:1450:4010:c03::236]) by mx1.freebsd.org (Postfix) with ESMTP id BB8B6648; Thu, 28 Feb 2013 17:37:38 +0000 (UTC) Received: by mail-la0-f54.google.com with SMTP id gw10so2069204lab.13 for ; Thu, 28 Feb 2013 09:37:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=jCdrLhoE/cGnjXIpGbqErhcv/tx4PuHRtejlMG06LFE=; b=uC1hE68earCTHYv7JN5H1mVh8//msP77UA9qbAY3NqGGYTMrXQH06TJb4zAOXxGQmX G4DkJLObHtZCzuSmv22wr0s/Rq1gPyf8wIcwBlipCL1G021YdW70FTV0/CphyIyiOaV2 G4BerHEkMP3BGVwpMdJohouF2i+gLNgAITcsN9oiOoNqSHPH6NCnxU6/yiSvbvRY1LVB 0wBbQjny7mFjJ9XVDbJMmI3tvWfkbDcdwfOzCmyJh0FEnhE9Tuc63NwG2ZDTrJDD6Qu6 QOsX8VhU3RhY0P5XzlMvBFKALjJQbK7Ox/hwZeXRfOvncDyZxhK1HYDbAAUpmJfe6bGL lf8A== X-Received: by 10.112.87.132 with SMTP id ay4mr3906045lbb.87.1362073057587; Thu, 28 Feb 2013 09:37:37 -0800 (PST) Received: from mavbook.mavhome.dp.ua (mavhome.mavhome.dp.ua. [213.227.240.37]) by mx.google.com with ESMTPS id g6sm3176128lbd.14.2013.02.28.09.37.34 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Feb 2013 09:37:36 -0800 (PST) Sender: Alexander Motin Message-ID: <512F95DC.1040005@FreeBSD.org> Date: Thu, 28 Feb 2013 19:37:32 +0200 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130125 Thunderbird/17.0.2 MIME-Version: 1.0 To: Alexey Dokuchaev Subject: Re: svn commit: r247460 - head/sys/dev/acpica References: <201302281127.r1SBR2VE068276@svn.freebsd.org> <20130228162522.GA41693@FreeBSD.org> In-Reply-To: <20130228162522.GA41693@FreeBSD.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Davide Italiano , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Feb 2013 17:37:40 -0000 On 28.02.2013 18:25, Alexey Dokuchaev wrote: > On Thu, Feb 28, 2013 at 11:27:02AM +0000, Davide Italiano wrote: >> New Revision: 247460 >> URL: http://svnweb.freebsd.org/changeset/base/247460 >> >> Log: >> MFcalloutng (r247427 by mav): >> We don't need any precision here. Let it be fast and dirty shift then >> slow and excessively precise 64-bit division. >> >> - if (sbt >= 0 && us > sbt / SBT_1US) >> - us = sbt / SBT_1US; >> + if (sbt >= 0 && us > (sbt >> 12)) >> + us = (sbt >> 12); > > Does this really buy us anything? Modern compilers should be smart enough to > generate correct code. Do you have evidence that this is not the case here? > Not to mention that it obfuscates the code by using some magic constant. SBT_1US is 4294 (0x10c6). The best that compiler may do is replace division with multiplication. In fact, Clang even does this on amd64. But on i386 it calls __divdi3(), doing 64bit division in software. Shift is definitely cheaper and 5% precision is fine here. -- Alexander Motin