summaryrefslogtreecommitdiff
path: root/testsuite/tests/eyeball/inline2.hs
blob: e77e815414f85e6f4c89cefe9585e8fdf18ac904 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{-# OPTIONS -fglasgow-exts -O -dshow-passes #-}

module Foo where
import GHC.Base

foo :: Int -> Int
foo (I# n#) = bar i i
   where i# = n# +# 1#
         i  = I# i#

bar :: Int -> Int -> Int
{-# INLINE [0] bar #-}
bar _ n = n

{-   The trouble here was

    *** Simplify:
         Result size = 25
         Result size = 25
         Result size = 25
         Result size = 25
         Result size = 25
    *** Simplify:
         Result size = 25
         Result size = 25
         Result size = 25
         Result size = 25
         Result size = 25


    etc.

The reason was this:
        x = n# +# 1#
        i = I# x

Being an unboxed value, we were treating the argument context of x
as interesting, and hence inlining x in the arg of I#. But then we just
float it out again, giving an infinite loop.
-}