Re: Branchless implementation for literal case – is it worth it?

2015-04-20 Thread Sven Panne
2015-04-19 9:44 GMT+02:00 Joachim Breitner m...@joachim-breitner.de: [...] So my question to the general audience: Is such branchless code really better than the current, branching code? Can someone provide us with an example that shows that it is better? Do I need to produce different

Re: Branchless implementation for literal case – is it worth it?

2015-04-20 Thread Joachim Breitner
Hi, Am Montag, den 20.04.2015, 16:29 +0200 schrieb Sven Panne: 2015-04-19 9:44 GMT+02:00 Joachim Breitner m...@joachim-breitner.de: [...] So my question to the general audience: Is such branchless code really better than the current, branching code? Can someone provide us with an example

Fwd: Re: Branchless implementation for literal case – is it worth it?

2015-04-20 Thread Niculae Ionita
Sorry, I forgot to answer to the list. If the code is already there and some architectures can profit of it, especially in inner loops - why not just make it an optimisation flag? Nicu Am 20.04.2015 um 16:41 schrieb Joachim Breitner: Hi, Am Montag, den 20.04.2015, 16:29 +0200 schrieb Sven

Re: Fwd: Re: Branchless implementation for literal case – is it worth it?

2015-04-20 Thread Joachim Breitner
Hi, Am Montag, den 20.04.2015, 19:45 +0200 schrieb Niculae Ionita: Sorry, I forgot to answer to the list. ah, and sorry for telling you so before looking on the list. If the code is already there and some architectures can profit of it, especially in inner loops - why not just make it an

Re: Branchless implementation for literal case – is it worth it?

2015-04-20 Thread Gregory Collins
I've gotten substantial speedups (30%) in the past (e.g. in the hashtables package) by replacing search loops with branchless code, but the technique works best in situations where you have a long run of straight-line integer code for the CPU to chew on; for branchless to be a win you need to feed

Re: Branchless implementation for literal case – is it worth it?

2015-04-20 Thread Sven Panne
2015-04-20 16:41 GMT+02:00 Joachim Breitner m...@joachim-breitner.de: The conclusion I draw from your mail, at last for our case, is: Don’t bother (and keep the compiler code simple). Is that a correct reading? Yes, I think that's the right approach. Do simple things like e.g. a distinction

Re: Branchless implementation for literal case – is it worth it?

2015-04-20 Thread Dan Doel
On Mon, Apr 20, 2015 at 10:29 AM, Sven Panne svenpa...@gmail.com wrote: * On more powerful cores with heavy out-of-order execution, it's hard to beat a well-predicted branch. ​With regard to this, I was wondering if we have a way of arranging for good branch prediction in GHC. For

Re: Branchless implementation for literal case – is it worth it?

2015-04-19 Thread Johan Tibell
On Apr 19, 2015 09:44, Joachim Breitner m...@joachim-breitner.de wrote: Dear devs, in https://ghc.haskell.org/trac/ghc/ticket/10124 bgamari suggested that code like f :: Int - Bool f a = case a of 1 - True 5 - True 8 -

Re: Branchless implementation for literal case – is it worth it?

2015-04-19 Thread Ben Gamari
Joachim Breitner m...@joachim-breitner.de writes: Dear devs, in https://ghc.haskell.org/trac/ghc/ticket/10124 bgamari suggested that code like f :: Int - Bool f a = case a of 1 - True 5 - True 8 - True

Re: Branchless implementation for literal case – is it worth it?

2015-04-19 Thread Carter Schonwald
the optimization manual ben mentions is http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-optimization-manual.html it does a very good job laying out the scope of both *generality* and *impact* for a huge range of systemsy tricks. there are certain

Re: Branchless implementation for literal case – is it worth it?

2015-04-19 Thread Gabor Greif
Em domingo, 19 de abril de 2015, Joachim Breitner m...@joachim-breitner.de escreveu: Dear devs, in https://ghc.haskell.org/trac/ghc/ticket/10124 bgamari suggested that code like f :: Int - Bool f a = case a of 1 - True 5 - True