Received: from [140.186.70.92] (port=46910 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pwsbu-0006Wp-HN for qemu-devel@nongnu.org; Tue, 08 Mar 2011 03:49:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pwsbt-0002tO-5F for qemu-devel@nongnu.org; Tue, 08 Mar 2011 03:49:42 -0500 Received: from [88.191.126.93] (port=46723 helo=hall.aurel32.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pwsbs-0002tA-Vm for qemu-devel@nongnu.org; Tue, 08 Mar 2011 03:49:41 -0500 Date: Tue, 8 Mar 2011 09:49:38 +0100 From: Aurelien Jarno Subject: Re: [Qemu-devel] [PATCH v5 04/10] softfloat: Drop [u]int16 types in favor of [u]int_fast16_t Message-ID: <20110308084938.GG10422@hall.aurel32.net> References: <1294169951-5153-5-git-send-email-andreas.faerber@web.de> <1299458053-69428-1-git-send-email-andreas.faerber@web.de> <1299458053-69428-2-git-send-email-andreas.faerber@web.de> <1299458053-69428-3-git-send-email-andreas.faerber@web.de> <1299458053-69428-4-git-send-email-andreas.faerber@web.de> <20110307095623.GA29308@hall.aurel32.net> <20110307233755.GE10422@hall.aurel32.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: Sender: Aurelien Jarno List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Andreas =?iso-8859-15?Q?F=E4rber?= , qemu-devel@nongnu.org On Tue, Mar 08, 2011 at 08:29:50AM +0000, Peter Maydell wrote: > On 7 March 2011 23:37, Aurelien Jarno wrote: > > I understand your point, but OTOH int_fast16_t means at least int16_t so > > in practice it doesn't bring anything more than changing to int16_t, > > except more pain as the size actually depends on the host. > > But at the moment we implement int16 as int, so (a) we'd be telling > the compiler it needed to use a type that was (fractionally) less > efficient and (b) we already know that the code can cope with the > type being wider than 16 bits, because that's how we're compiling > the code today. The thing we should be worrying about is that maybe > there's code that accidentally requires more than 16 bits in an > int16 which would break if you defined it as an int16_t... And it might also break with int_fast16_t as it only guarantees int16_t at the minimum. So using int_fast16_t doesn't bring more safety than int16_t here. Also currently we define int16 as int, so it has the same size everywhere. int_fast16_t size is varying depending on the host. > > > If we want to change the int here, we should either use int32_t here > > (which matches the size of int), or just look case by case and use the > > correct type. > > Correct choice between 'bits16' and 'uint16' is actually one of > the areas where I pretty much trust the original softfloat code: > I think it's definitely a retrograde step to throw that away, > and personally I would NAK any patch which merges the two together > into a single typename. On most systems uint_fastxx_t types is defined in the preprocessor, so the compiler can't really exploit this. We are in 2010 and compilers are able to compile code using 16-, 32- or 64-bit ops for an uint16_t if it's faster on this architecture, while guaranteeing that the result would be the same than an uint16_t. By using uint_fast16_t we simply force the compiler to use a 64-bit op on a 64-bit machine, even if it has only have 16-bits to handle. Also a lot of functions in softfloat are static or inline functions, so the compiler can do a lot of optimizations if the type is not overestimated. In any case, I would NAK any patch that are using different size depending on the host, as it is a real nightmare to handle, and there is no real point to do that. Andreas has shown we can have code that compiles on 32-bit, but not on 64-bit. That's the best case, we can also have different results on 32-bit than 64-bit, and it's a lot more difficult to detect. -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net