Commit a730d649 authored by simonpj's avatar simonpj

[project @ 2004-01-08 11:50:41 by simonpj]

Add a CSE with unboxed tuples test
parent e418c720
......@@ -11,3 +11,4 @@ setTestOpts(f)
test('simplrun001', normal, compile_and_run, [''])
test('simplrun002', normal, compile_and_run, [''])
test('simplrun003', normal, compile_and_run, ['-O2'])
{-# OPTIONS -fglasgow-exts -O2 #-}
-- O2 to get CSE
module Main where
f :: Int -> (# Int, Int #)
f 0 = (# 1,2 #)
f n = f (n-1)
{-# NOINLINE g #-}
g x = case f x of
(# a,b #) -> if a>0
then f x -- CSE opportunity
else (# b,a #)
-- GHC 6.2 wrongly optimised g to:
-- case f x of t
-- (# a,b #) -> if a>0 then
-- t -- WRONG
-- else (# b,a #)
main = case g 2 of (# a,b #) -> print a
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment