[Haskell] Expecting more inlining for bit shifting

roconnor at theorem.ca roconnor at theorem.ca
Wed Oct 11 14:00:17 EDT 2006


On Wed, 11 Oct 2006, Samuel Bronson wrote:

> branch. I've got a patch that seems like it ought to do a bettter job, 
> but it doesn't seem to give the $wrotate functions any discount (the 
> $wshift functions having been tagged by the {-# INLINE shift #-} pragmas 
> I added all over). Unfortunately I left it at home and I'm at school 
> right now :-(. It does get run sometimes, but I'm not sure if it is run 
> for rotate or that its results are kept...

The problem with rotate is that it is:

(W32# x#) `rotate` (I# i#)
         | i'# ==# 0# = W32# x#
         | otherwise  = W32# (narrow32Word# ((x# `shiftL#` i'#) `or#`
                                             (x# `shiftRL#` (32# -# i'#))))
         where
         i'# = word2Int# (int2Word# i# `and#` int2Word# 31#)

The i'# gets inlined, so the case statement isn't actually actually doing 
an analysis on i#, rather it is doing an analysis on
  i# `and#` 31#.

So this lends support to SPJ's view that we need to check to see if a 
variable is being used in an application of a primop that can be 
evaluated, and all the other arguements are literals.

-- 
Russell O'Connor                                      <http://r6.ca/>
``All talk about `theft,''' the general counsel of the American Graphophone
Company wrote, ``is the merest claptrap, for there exists no property in
ideas musical, literary or artistic, except as defined by statute.''


More information about the Glasgow-haskell-users mailing list