From owner-cvs-all@FreeBSD.ORG Mon Oct 29 21:15:59 2007 Return-Path: Delivered-To: cvs-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9028D16A46B for ; Mon, 29 Oct 2007 21:15:59 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id D743413C4D1 for ; Mon, 29 Oct 2007 21:15:58 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: (qmail invoked by alias); 29 Oct 2007 20:48:16 -0000 Received: from p54A3ECF4.dip.t-dialin.net (EHLO tron.homeunix.org) [84.163.236.244] by mail.gmx.net (mp004) with SMTP; 29 Oct 2007 21:48:16 +0100 X-Authenticated: #1673122 X-Provags-ID: V01U2FsdGVkX18UuDU1LyYUxNCZiIMVog9/xGf/HJHjf2rRW6UZ8V +epcDLrhSHVeGY Message-ID: <47264710.2000500@gmx.de> Date: Mon, 29 Oct 2007 21:48:16 +0100 From: Christoph Mallon User-Agent: Thunderbird 2.0.0.6 (X11/20070806) MIME-Version: 1.0 To: "Andrey A. Chernov" References: <200710272232.l9RMWSbK072082@repoman.freebsd.org> In-Reply-To: <200710272232.l9RMWSbK072082@repoman.freebsd.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/include _ctype.h X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Oct 2007 21:15:59 -0000 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. Christoph