#4823: Loop strength reduction for array indexing
---------------------------------+------------------------------------------
    Reporter:  tibbe             |       Owner:              
        Type:  feature request   |      Status:  new         
    Priority:  normal            |   Component:  Compiler    
     Version:  7.1               |    Keywords:              
    Testcase:                    |   Blockedby:              
          Os:  Unknown/Multiple  |    Blocking:              
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown
---------------------------------+------------------------------------------
 Indexing into a `ByteArray#` in a loop is currently more expensive than
 working on a `ForeignPtr` due to lack of strength reduction. Pointer
 arithmetic is cheaper than using base + offset indexing. We could convert
 indexing into pointer arithmetic if it weren't for the GC being able to
 move objects around.

 Tom Rodriguez had the following to say about Java HotSpot and loop
 strength reduction:

 > "The server compiler doesn't do explicit loop strength reduction though
 it can get a bit of it as a result of other transformations loop invariant
 code motion.  I've played a bit with doing it more explicitly but had some
 difficulty getting benefit from it.  The resulting pointers are handled by
 the notion of derived pointers.  These are interior pointers that are
 tracked along with their base pointers.  At the beginning of GC the offset
 from the base of the derived pointer is saved and the pointer is converted
 to the base and after GC the offset is added back in.  That part all
 happens automatically.  Searching for DerivedPointer will lead you to the
 relevant code."

 Perhaps it's an idea we could try?

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4823>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to