summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/indexed-types/should_compile/ATLoop.hs
blob: 19f9e5b8a2c937ecc6d57adbbc4b2ef5f64bbe34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{-# OPTIONS_GHC -O2 #-}

-- Reading the interface file caused a black hole
-- in earlier versions of GHC

-- Also, foo should compile to very tight code with -O2
-- (The O2 was nothing to do with the black hole though.)

module ShouldCompile where

import ATLoop_help

foo :: FooT Int -> Int -> Int
foo t n = t `seq` bar n
   where
     bar 0 = 0
     bar n | even n = bar (n `div` 2)
     bar n          = bar (n - int t)