Inline Data.Bits.rotate@Int, enables rotate to be constant folded
authorDon Stewart <dons@galois.com>
Thu, 1 May 2008 23:01:52 +0000 (23:01 +0000)
committerDon Stewart <dons@galois.com>
Thu, 1 May 2008 23:01:52 +0000 (23:01 +0000)
commit6ddafc80ab8e5b76dd678cb4523a02db49fc67d8
tree47534763782524af0fcf2c446cda57554b9125a8
parent56e2ad700b5e4d5d2a27a94bc55ce6bf5d2ed2fe
Inline Data.Bits.rotate@Int, enables rotate to be constant folded

All other Bits instances seem to inline well enough on their own
to enable constant folding, e.g.

    sumU . mapU (`shift` 3) . replicateU 10000000 $ (7 :: Int)

goes to:

    Main.$wfold =
      \ (ww_sOb :: Int#) (ww1_sOf :: Int#) ->
        case ww1_sOf of wild_XM {
          __DEFAULT -> Main.$wfold (+# ww_sOb 56) (+# wild_XM 1);
          10000000 -> ww_sOb
        }

With this patch, rotate gets inlined and folded too,

    sumU . mapU (`rotate` 3) . replicateU 10000000 $ (7 :: Int)

to:

  Main.$wfold =
    \ (ww_sO7 :: Int#) (ww1_sOb :: Int#) ->
      case ww1_sOb of wild_XM {
        __DEFAULT -> Main.$wfold (+# ww_sO7 56) (+# wild_XM 1);
        10000000 -> ww_sO7

Whereas it was left as a call to $wrotate before.
Data/Bits.hs