-O2

Saswat Anand saswat@comp.nus.edu.sg
Mon, 15 Apr 2002 16:30:49 +0800 (GMT-8)


Hi,

In my program I observe that, with -O2 flag turned on, Program 1 behaves
like Program 2. And without O2, their outputs are different.

Is it the desirable behaviour? For my program, I did not expect the
optimizer to do this transformation.



Thanks,
Saswat

Program 1:
eval = \..->       
      let t       = some_long_expression 
          tree q  = Tree (w:=q) some_long _expression
      in  if w /= 0 then concatMap (cc con1) [tree x | x <- [1..n]] 
                           else t 

Program 2:
eval = \..->       
      let t       = some_long_expression
          tree q  = Tree (w:=q) t         -- Here is the difference
      in  if w /= 0 then concatMap (cc con1) [tree x | x <- [1..n]] 
                           else t 


some_long_expression stands for, concatMap (cc con2) $ zipWith join (eval
v c1 (reverse v1)) (eval v c2 v2)