From owner-cvs-src@FreeBSD.ORG Wed Oct 31 22:29:27 2007 Return-Path: Delivered-To: cvs-src@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C0EF16A418; Wed, 31 Oct 2007 22:29:27 +0000 (UTC) (envelope-from ache@nagual.pp.ru) Received: from nagual.pp.ru (nagual.pp.ru [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id 11FAF13C4A7; Wed, 31 Oct 2007 22:29:26 +0000 (UTC) (envelope-from ache@nagual.pp.ru) Received: from nagual.pp.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.14.1/8.14.1) with ESMTP id l9VMJaQe090856; Thu, 1 Nov 2007 01:19:36 +0300 (MSK) (envelope-from ache@nagual.pp.ru) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nagual.pp.ru; s=default; t=1193869177; bh=ww3aC6MAyGQbPV+ft0eWc7FbDSPluzBN/vSWGx+ 0ZeE=; l=1901; h=Date:From:To:Cc:Subject:Message-ID: Mail-Followup-To:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:User-Agent; b=R7LdFKFcsfhCwHQ69RIk NQZyIVCXSPWITg/8+1PQIzqWnSpKRlSQ8cbGeoVQw8wnHQGIUWTaVXxUB0weO3LMGiG FBL3ymYWc0FwRQUy/t/krJtZYemZbKTyXkWo87b2lvK7RSzehk1aBNV1kKR6Iro6wSG YKLD/SwmBhMccgYvM= Received: (from ache@localhost) by nagual.pp.ru (8.14.1/8.14.1/Submit) id l9VMJa0a090855; Thu, 1 Nov 2007 01:19:36 +0300 (MSK) (envelope-from ache) Date: Thu, 1 Nov 2007 01:19:35 +0300 From: Andrey Chernov To: Christoph Mallon Message-ID: <20071031221934.GA90781@nagual.pp.ru> Mail-Followup-To: Andrey Chernov , Christoph Mallon , src-committers@FreeBSD.ORG, cvs-src@FreeBSD.ORG, cvs-all@FreeBSD.ORG References: <200710272232.l9RMWSbK072082@repoman.freebsd.org> <47264710.2000500@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47264710.2000500@gmx.de> User-Agent: Mutt/1.5.16 (2007-06-09) Cc: cvs-src@FreeBSD.ORG, src-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/include _ctype.h X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Oct 2007 22:29:27 -0000 On Mon, Oct 29, 2007 at 09:48:16PM +0100, Christoph Mallon wrote: > Andrey A. Chernov wrote: >> ache 2007-10-27 22:32:28 UTC >> FreeBSD src repository >> Modified files: >> include _ctype.h Log: >> Micro-optimization of prev. commit, change >> (_c < 0 || _c >= 128) to (_c & ~0x7F) >> Revision Changes Path >> 1.33 +1 -1 src/include/_ctype.h > > Actually this is rather a micro-pessimisation. Every compiler worth its > money transforms the range check into single unsigned comparison. The > latter test on the other hand on x86 gets probably transformed into a test > instruction. This instruction has no form with sign extended 8bit > immediate, but only with 32bit immediate. This results in a significantly > longer opcode (three bytes more) than a single (unsigned)_c > 127, which a > sane compiler produces. I suspect some RISC machines need one more > instruction for the "micro-optimised" code, too. > In theory GCC could transform the _c & ~0x7F back into a (unsigned)_c > > 127, but it does not do this (the only compiler I found, which does this > transformation, is LLVM). > Further IMO it is hard to decipher what _c & ~0x7F is supposed to do. 1. My variant is compiler optimization level independent. F.e. without optimization completely there is no range check transform you talk about at all and very long asm code is generated. I also mean the case where gcc optimization bug was avoided, removing optimization (like compiling large part of Xorg server recently), using non-gcc compilers etc. cases. 2. _c & ~0x7F comes right from is{w}ascii() so there is no such enormously big problems to decifer. I just want to keep all ctype in style. 3. I see no "longer opcode (three bytes more)" you talk about in my tests (andl vs cmpl was there, no testl). -- http://ache.pp.ru/