Path: csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Stefan Reuther Newsgroups: comp.arch.embedded Subject: Re: Slightly OT: speed of operation on a PC Date: Wed, 05 Aug 2015 18:43:29 +0200 Lines: 23 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: individual.net BASHGRk7HMkdV4RJ5zXxAAQvX252/b9TTFgQNMNyonRMqy0oeU Cancel-Lock: sha1:XiRJlNh3wRHgv2dLGRkI3pHniOo= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3.1) Gecko/20030425 Hamster/2.1.0.1538 X-Accept-Language: en-us, en In-Reply-To: Xref: csiph.com comp.arch.embedded:21674 Tim Wescott wrote: > Which do you think is quicker on a PC, with the latest gnu compiler: > > double a = something; > double b = something else; > > if (a >= 0.0 && b < 0.0) > > >>or << > > if (a * b <= 0) I cannot get my compilers to generate anything else than two branches for the first case, which would mean the second one is faster on average (except if a were >= 0.0 in the vast majority of cases). If I had to process these values in bulk, and didn't have to care for things like NaNs, I'd probably try to play some tricks with (integer) SIMD instructions. Stefan