Re: Loop optimisation with identical counters

2010-11-10 Thread Simon Marlow
On 08/11/2010 15:44, Max Bolingbroke wrote: On 6 November 2010 04:47, David Peixottod...@rice.edu wrote: Are you sure about R1 aliasing Sp? AFAIK, R1 points to a closure on the heap, not to a stack location. That is, it can alias pointers on the stack or Hp but it can't alias the Sp itself.

Re: Loop optimisation with identical counters

2010-11-08 Thread Max Bolingbroke
On 6 November 2010 04:47, David Peixotto d...@rice.edu wrote: Are you sure about R1 aliasing Sp? AFAIK, R1 points to a closure on the heap, not to a stack location. That is, it can alias pointers on the stack or Hp but it can't alias the Sp itself. I don't think Sp can be aliased by

Re: Loop optimisation with identical counters

2010-11-06 Thread christian Hoener zu Siederdissen
Yes indeed, this is what some fusion code could look like. I deal with stuff like this: mk i j = enumFromN (i+1) (j-i-2) -- gen indices, sometimes index pairs f i j k = T!(i,k) + T!(k+1,j) -- table lookup using some 2d tables g i j k = fun i k + fun (k+1) j -- some funny calculation z i j =

Re: Loop optimisation with identical counters

2010-11-05 Thread David Peixotto
...@haskell.org [mailto:glasgow-haskell-users- | boun...@haskell.org] On Behalf Of Roman Leshchinskiy | Sent: 03 November 2010 10:55 | To: Christian Hoener zu Siederdissen | Cc: glasgow-haskell-users@haskell.org | Subject: Re: Loop optimisation with identical counters | | LLVM doesn't

Re: Loop optimisation with identical counters

2010-11-05 Thread Roman Leshchinskiy
On 05/11/2010, at 23:22, David Peixotto wrote: I spent some time looking at the code generated for llvm and the optimizations it can apply. There were quite a bit of details to examine and I wrote it up as blog post here:

Re: Loop optimisation with identical counters

2010-11-05 Thread David Peixotto
Hi Roman, On Nov 5, 2010, at 6:44 PM, Roman Leshchinskiy wrote: On 05/11/2010, at 23:22, David Peixotto wrote: I spent some time looking at the code generated for llvm and the optimizations it can apply. There were quite a bit of details to examine and I wrote it up as blog post here:

Re: Loop optimisation with identical counters

2010-11-05 Thread Roman Leshchinskiy
On 06/11/2010, at 00:28, David Peixotto wrote: Yes, the LLVM code has Sp, Hp, Base all annotated as noalias. I believe that Sp, Hp, and Base should never alias, but a (boxed) R1 should always alias with either Sp or Hp. I had a hard time determining exactly how LLVM uses the noalias

Re: Loop optimisation with identical counters

2010-11-05 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/5/10 19:22 , David Peixotto wrote: Probably there are some wins to be had by choosing a good optimization sequence for the code generated from GHC, rather than just using `-O1`, `-O2`, etc. I believe It should be possible to find

Re: Loop optimisation with identical counters

2010-11-05 Thread Sebastian Fischer
On Nov 6, 2010, at 8:22 AM, David Peixotto wrote: To summarize, I found that it is possible to get LLVM to do this transformation through a combination of tail-call elimination, inlining, induction variable optimization, and global value numbering. Interesting. This approach requires `f`

Re: Loop optimisation with identical counters

2010-11-05 Thread Roman Leshchinskiy
On 06/11/2010, at 02:27, Sebastian Fischer wrote: Interesting. This approach requires `f` to be inlined into its call site in order to eliminate the redundant argument. This is different from the proposal to provide a specialized version of `f` (where the arguments are combined) which

Re: Loop optimisation with identical counters

2010-11-05 Thread David Peixotto
On Nov 5, 2010, at 7:55 PM, Roman Leshchinskiy wrote: On 06/11/2010, at 00:28, David Peixotto wrote: Yes, the LLVM code has Sp, Hp, Base all annotated as noalias. I believe that Sp, Hp, and Base should never alias, but a (boxed) R1 should always alias with either Sp or Hp. I had a hard

Re: Loop optimisation with identical counters

2010-11-05 Thread David Peixotto
On Nov 5, 2010, at 8:56 PM, Brandon S Allbery KF8NH wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/5/10 19:22 , David Peixotto wrote: Probably there are some wins to be had by choosing a good optimization sequence for the code generated from GHC, rather than just using

Re: Loop optimisation with identical counters

2010-11-05 Thread Sebastian Fischer
Which proposal do you mean? I referred to Christian's questions whether it is possible to generate `ff` and `gg` from `f` and `g`. If `h` is similar to `g`, then `hh` could reuse `ff` while with an inlining approach something like `ff` would be duplicated. I'm not sure something like

RE: Loop optimisation with identical counters

2010-11-04 Thread Simon Peyton-Jones
| To: Christian Hoener zu Siederdissen | Cc: glasgow-haskell-users@haskell.org | Subject: Re: Loop optimisation with identical counters | | LLVM doesn't eliminate the counters. FWIW, fixing this would improve performance of | stream fusion code quite a bit. It's very easy to do in Core. | | Roman

Re: Loop optimisation with identical counters

2010-11-04 Thread Christian Hoener zu Siederdissen
] On Behalf Of Roman Leshchinskiy | Sent: 03 November 2010 10:55 | To: Christian Hoener zu Siederdissen | Cc: glasgow-haskell-users@haskell.org | Subject: Re: Loop optimisation with identical counters | | LLVM doesn't eliminate the counters. FWIW, fixing this would improve performance

Re: Loop optimisation with identical counters

2010-11-03 Thread Christian Hoener zu Siederdissen
Thanks, I'll do some measurements on this with ghc7. Gruss, Christian On 11/02/2010 01:23 PM, Simon Marlow wrote: On 02/11/2010 08:17, Christian Höner zu Siederdissen wrote: Hi, is the following problem a job for ghc or the code generation backend (llvm)? We are given this program: {-#

Re: Loop optimisation with identical counters

2010-11-03 Thread Roman Leshchinskiy
On 3 Nov 2010, at 10:45, Christian Hoener zu Siederdissen choe...@tbi.univie.ac.at wrote: Thanks, I'll do some measurements on this with ghc7. Gruss, Christian On 11/02/2010 01:23 PM, Simon Marlow wrote: On 02/11/2010 08:17, Christian Höner zu Siederdissen wrote: Hi, is the

Re: Loop optimisation with identical counters

2010-11-03 Thread Roman Leshchinskiy
LLVM doesn't eliminate the counters. FWIW, fixing this would improve performance of stream fusion code quite a bit. It's very easy to do in Core. Roman On 3 Nov 2010, at 10:45, Christian Hoener zu Siederdissen choe...@tbi.univie.ac.at wrote: Thanks, I'll do some measurements on this with

Re: Loop optimisation with identical counters

2010-11-03 Thread Christian Hoener zu Siederdissen
Is there a ticket for this (didn't find one)? Or should there be? For some reason, I'd like to see this in ghc ;-) Gruss, Christian On 11/03/2010 11:54 AM, Roman Leshchinskiy wrote: LLVM doesn't eliminate the counters. FWIW, fixing this would improve performance of stream fusion code quite a

Loop optimisation with identical counters

2010-11-02 Thread Christian Höner zu Siederdissen
Hi, is the following problem a job for ghc or the code generation backend (llvm)? We are given this program: {-# LANGUAGE BangPatterns #-} module Main where f :: Int - Int - Int - Int - Int f !i !j !s !m | i == 0= s+m | otherwise = f (i-1) (j-1) (s + i+1) (m + j*5) g :: Int - Int g

Re: Loop optimisation with identical counters

2010-11-02 Thread Simon Marlow
On 02/11/2010 08:17, Christian Höner zu Siederdissen wrote: Hi, is the following problem a job for ghc or the code generation backend (llvm)? We are given this program: {-# LANGUAGE BangPatterns #-} module Main where f :: Int - Int - Int - Int - Int f !i !j !s !m | i == 0= s+m