This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Design for flag bit outputs from asms
- From: "H. Peter Anvin" <hpa at zytor dot com>
- To: Richard Henderson <rth at redhat dot com>, Linus Torvalds <torvalds at linux-foundation dot org>
- Cc: Peter Zijlstra <peterz at infradead dot org>, Vladimir Makarov <vmakarov at redhat dot com>, Jakub Jelinek <jakub at redhat dot com>, Ingo Molnar <mingo at kernel dot org>, Thomas Gleixner <tglx at linutronix dot de>, Linux Kernel Mailing List <linux-kernel at vger dot kernel dot org>, Borislav Petkov <bp at alien8 dot de>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Mon, 04 May 2015 14:23:01 -0700
- Subject: Re: [RFC] Design for flag bit outputs from asms
- Authentication-results: sourceware.org; auth=none
- References: <20150501151630 dot GH5029 at twins dot programming dot kicks-ass dot net> <CA+55aFwBP9QjpRK50pdVHmc086-+QPCthJRUs8Gq5qJBnXqnJQ at mail dot gmail dot com> <20150501163329 dot GU1751 at tucnak dot redhat dot com> <5543CDC0 dot 6010206 at redhat dot com> <CA+55aFxOd6mJcezgoLHN9Zgds-CsJqsx4Jgkp9OP1xUf11727Q at mail dot gmail dot com> <20150502123958 dot GK5029 at twins dot programming dot kicks-ass dot net> <5547C992 dot 9000703 at redhat dot com> <5547D30B dot 2020507 at zytor dot com> <5547D7A3 dot 2010203 at redhat dot com> <CA+55aFz9jW_ii58pMtmVipEmDWfWak0eL47oH_nik4G97Jo72w at mail dot gmail dot com> <5547DD29 dot 2020805 at redhat dot com>
On 05/04/2015 01:57 PM, Richard Henderson wrote:
>
> Sure.
>
> I'd be more inclined to support these compound conditionals directly, rather
> than try to get the compiler to recognize them after the fact.
>
> Indeed, I believe we have a near complete set of them in the x86 backend
> already. It'd just be a matter of selecting the spellings for the constraints.
>
Whichever works for you.
The full set of conditions, mnemonics, and a bitmask with the bits in
the order from MSB to LSB (OF,SF,ZF,PF,CF) which is probably the sanest
way to model these for the purpose of boolean optimization.
Opcode Mnemonics Condition Bitmask
0 o OF 0xffff0000
1 no !OF 0x0000ffff
2 b/c/nae CF 0xaaaaaaaa
3 ae/nb/nc !CF 0x55555555
4 e/z ZF 0xf0f0f0f0
5 ne/nz !ZF 0x0f0f0f0f
6 na CF || ZF 0xfafafafa
7 a !CF && !ZF 0x05050505
8 s SF 0xff00ff00
9 ns !SF 0x00ff00ff
A p/pe PF 0xcccccccc
B np/po !PF 0x33333333
C l/nge SF != OF 0x00ffff00
D ge/nl SF == OF 0xff0000ff
E le/ng ZF || (SF != OF) 0xf0fffff0
F g/nle !ZF && (SF == OF) 0x0f00000f
-hpa