From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424077AbcFHJkI (ORCPT ); Wed, 8 Jun 2016 05:40:08 -0400 Received: from merlin.infradead.org ([205.233.59.134]:57555 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423798AbcFHJkB (ORCPT ); Wed, 8 Jun 2016 05:40:01 -0400 Date: Wed, 8 Jun 2016 11:39:47 +0200 From: Peter Zijlstra To: "H. Peter Anvin" Cc: Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner , Linux Kernel Mailing List , Andy Lutomirski , Borislav Petkov , Linus Torvalds , Arnd Bergmann Subject: Re: [PATCH 02/10] x86, asm: use bool for bitops and other assembly outputs Message-ID: <20160608093947.GQ30154@twins.programming.kicks-ass.net> References: <1465342269-492350-1-git-send-email-hpa@linux.intel.com> <1465342269-492350-3-git-send-email-hpa@linux.intel.com> <20160608074956.GO30154@twins.programming.kicks-ass.net> <20160608082835.GB9645@gmail.com> <20160608083340.GC9645@gmail.com> <02ee64ce-257a-ba93-1f49-6877f5e4f6db@zytor.com> <20160608090111.GA11390@gmail.com> <88387994-fbf1-83dd-d58d-343498776a11@zytor.com> <20160608092040.GA17389@gmail.com> <9ce48c59-4b9c-bd48-ce07-b230376fba0f@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9ce48c59-4b9c-bd48-ce07-b230376fba0f@zytor.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 08, 2016 at 02:31:31AM -0700, H. Peter Anvin wrote: > On 06/08/16 02:20, Ingo Molnar wrote: > > > > Yeah, absolutely. I hate 'bool' with a vengence but if 'int' generates worse code > > with modern compilers then I'm not going to argue for worse code. Would a 'char' > > return type be very weird? > > > > Yes. I have to admit I don't share your hatred for "bool" -- it gives > the compiler a fairly crucial bit of information about what the possible > values are for a certain piece of data. > > Upcasting to char loses that, and may case gcc to manifest the value as > an integer instead of retaining it in the flags. It is, however, less > likely to cause gcc to then try to widen the value to word size (which > is an extra instruction on x86), but moving the value out of and back > into the flags register is the big cost. So I think using bool as return type or argument is fine, using it in structures is 'insane'.