From owner-freebsd-chat Mon Mar 10 10:38:14 2003 Delivered-To: freebsd-chat@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D9DC737B401; Mon, 10 Mar 2003 10:38:12 -0800 (PST) Received: from cirb503493.alcatel.com.au (c18609.belrs1.nsw.optusnet.com.au [210.49.80.204]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3D92C43FA3; Mon, 10 Mar 2003 10:38:10 -0800 (PST) (envelope-from peterjeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1]) by cirb503493.alcatel.com.au (8.12.6/8.12.5) with ESMTP id h2AIc8iM004414; Tue, 11 Mar 2003 05:38:08 +1100 (EST) (envelope-from jeremyp@cirb503493.alcatel.com.au) Received: (from jeremyp@localhost) by cirb503493.alcatel.com.au (8.12.6/8.12.5/Submit) id h2AHvdib004352; Tue, 11 Mar 2003 04:57:39 +1100 (EST) Date: Tue, 11 Mar 2003 04:57:39 +1100 From: Peter Jeremy To: chat@FreeBSD.ORG Cc: "Tim J. Robbins" , Mark Murray Subject: Re: cvs commit: src/lib/libc/i386/string Makefile.inc wcscmp.S Message-ID: <20030310175739.GA4311@cirb503493.alcatel.com.au> References: <200303101054.h2AAsaKu089414@repoman.freebsd.org> <200303101238.h2ACcaIg077406@grimreaper.grondar.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200303101238.h2ACcaIg077406@grimreaper.grondar.org> User-Agent: Mutt/1.4i Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org [Please copy me on any followups] On Mon, Mar 10, 2003 at 12:38:36PM +0000, Mark Murray wrote: >"Tim J. Robbins" writes: >> MFp4: Pentium-optimised implementation of wcscmp(). Performs significantly >> better than the code generated by gcc in many cases. > >is this the sort of thing that a compiler _in_theory_ could/should do >well, or is this the kind of assembler code that only a human could be >expected to come up with? In theory, there's no reason why a computer application can't do anything a human could do. In practice this is a lot more difficult. It would be fairly simple to get a compiler to do boilerplate code substitution: if (cpu==Pentium && function=="wcscmp") emit code. This just moves the code for wcsmp.S into the gcc back-end - where it is still MD but now in a format that fewer people can understand and still fewer would feel comfortable in modifying. In general, the best optimisations are achieved at a much higher level than compilers can easily achieve. My favourite example of this is the original code for compress(1) - which turns about 1/2 page of C code into a single VAX instruction. You're not going to get a compiler to recognize this level of equivalence. >I'm not too charmed with MD code; the more that could be done by the >compiler, the more I like it. :-) I think you still wind up with just as much MD code, it's just hidden in the compiler. >iumop ap!sdn w,I idlaH Nice. Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message