summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore/should_compile/T19581.hs
blob: 448ce349d635abf1561bb8f5d722c253077079ff (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
{-# LANGUAGE MagicHash #-}

module Foo where

import GHC.Exts

g :: Int# -> Int#
{-# NOINLINE g #-}
g x = x +# 1#

-- Setting up this test case is quite delicate.
--
-- With the code below, simplification terminates too early.
--
-- Removing either of the (g (x +# 1#)) cases makes successively
-- merge 2 layers at a time, so it takes multiple iterations to
-- get a fixpoint.

f :: Int# -> Int#
f x = case g x of {
        1# -> 2# ; _ ->

      case g (x +# 1#) of { z ->

      case g x of {
        2# -> z ; _ ->

      case g (x +# 2#) of { z1 ->

      case g x of {
        3# -> 4#;  _ -> case g x of {
        4# -> z;   _ -> case g x of {
        5# -> 6#;  _ -> case g x of {
        6# -> z;   _ -> case g x of {
        7# -> 8#;  _ -> case g x of {
        8# -> 9#;  _ -> case g x of {
        9# -> 10#; _ -> 6#
        }}}}}}}}}}}