From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2827 invoked by alias); 29 Sep 2003 17:21:35 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 2820 invoked from network); 29 Sep 2003 17:21:34 -0000 Received: from unknown (HELO mail.jlokier.co.uk) (81.29.64.88) by sources.redhat.com with SMTP; 29 Sep 2003 17:21:34 -0000 Received: from mail.jlokier.co.uk (localhost [127.0.0.1]) by mail.jlokier.co.uk (8.12.8/8.12.8) with ESMTP id h8THLY0V022919; Mon, 29 Sep 2003 18:21:34 +0100 Received: (from jamie@localhost) by mail.jlokier.co.uk (8.12.8/8.12.8/Submit) id h8THLY8m022917; Mon, 29 Sep 2003 18:21:34 +0100 Date: Mon, 29 Sep 2003 17:38:00 -0000 From: Jamie Lokier To: Richard Henderson , David Howells , gcc@gcc.gnu.org Subject: Re: inline asm constraints for conditions Message-ID: <20030929172134.GE21798@mail.jlokier.co.uk> References: <8873.1064599632@redhat.com> <20030926203935.GB21887@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030926203935.GB21887@redhat.com> User-Agent: Mutt/1.4.1i X-SW-Source: 2003-09/txt/msg01238.txt.bz2 Richard Henderson wrote: > On Fri, Sep 26, 2003 at 07:07:12PM +0100, David Howells wrote: > > Would it be possible to get a new type of inline asm constraint added, such > > that a "condition" can be an output? > > Not like this, no. > > The most basic problem for x86 is that the flags register dies too often. > If we were to add the ability for it to live longer and be reloaded (say > with lahf/sahf), then generic parts of the compiler would start trying to > make use of it, which would almost certainly result in worse code overall > even when the feature was not in use. Why does it need the ability to be reloaded the whole flags? If the flags register is killed, then "reloading" should be a simple matter of either redoing the comparison, as effectively happens all the time now, or saving the _particular_ comparison results that are wanted using setcc, sbbl etc. into an ordinary register. Would it work to define a multitude of condition registers on the x86, one for each branch condition, like this: 1. cmp/sub set all the condition registers. 2. other flags-affecting instructions clobber all the condition registers or (in the case of inc/dec) just some of them. 3. branches and other conditionals use one of the many condition registers. 4. reload "moves" one condition register _to_ a general register or memory using setcc/sbb. 5. reload "moves" one condition register _from_ a general register or memory by doing a comparison against the saved value to set the real flags again. Of course this clobbers all the other condition registers :) Would this work? -- Jamie