Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752161AbbEDU26 (ORCPT ); Mon, 4 May 2015 16:28:58 -0400 Received: from terminus.zytor.com ([198.137.202.10]:40753 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751384AbbEDU2t (ORCPT ); Mon, 4 May 2015 16:28:49 -0400 Message-ID: <5547D64B.6060708@zytor.com> Date: Mon, 04 May 2015 13:27:55 -0700 From: "H. Peter Anvin" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Richard Henderson , Peter Zijlstra CC: Linus Torvalds , Vladimir Makarov , Jakub Jelinek , Ingo Molnar , Thomas Gleixner , Linux Kernel Mailing List , Borislav Petkov , "gcc@gcc.gnu.org" Subject: Re: [RFC] Design for flag bit outputs from asms References: <20150501151630.GH5029@twins.programming.kicks-ass.net> <20150501163329.GU1751@tucnak.redhat.com> <5543CDC0.6010206@redhat.com> <20150502123958.GK5029@twins.programming.kicks-ass.net> <5547C992.9000703@redhat.com> <5547D30B.2020507@zytor.com> In-Reply-To: <5547D30B.2020507@zytor.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1443 Lines: 53 On 05/04/2015 01:14 PM, H. Peter Anvin wrote: >> >> Therefore: >> >> (1) Each target defines a set of constraint strings, >> >> E.g. for x86, wherein we're almost out of constraint letters, >> >> ja aux carry flag >> jc carry flag >> jo overflow flag >> jp parity flag >> js sign flag >> jz zero flag >> > > I would argue that for x86 what you actually want is to model the > *conditions* that are available on the flags, not the flags themselves. > There are 16 such conditions, 8 if we discard the inversions. > > It is notable that the auxiliary carry flag has no Jcc/SETcc/CMOVcc > instructions; it is only ever consumed by the DAA/DAS instructions which > makes it pointless to try to model it in a compiler any more than, say, IF. > OK, let me qualify that. This is only necessary if it is impractical for gcc to optimize boolean combinations of flags. If such optimizations are available then it doesn't matter and is probably needlessly complex. For example: char foo(void) { bool zf, sf, of; asm("xyzzy" : "=jz" (zf), "=js" (sf), "=jo" (of)); return zf || (sf != of); } ... should compile to ... xyzzy setng %al ret -hpa -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/