Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/cfg-ir/value-numbering-fn.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/cfg-ir/value-numbering-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4402, Wed Aug 10 22:44:55 2016 UTC revision 4403, Wed Aug 10 22:51:46 2016 UTC
# Line 84  Line 84 
84      end (* local *)      end (* local *)
85    
86      fun rewriteCFG cfg = let      fun rewriteCFG cfg = let
87          (* rewrite or delete a node, if necessary.  Note that we have already rewritten the JOIN nodes *)          (* rewrite or delete a node, if necessary.  Note that we have already rewritten
88             * the JOIN nodes
89             *)
90            fun doNode nd = (case IR.Node.kind nd            fun doNode nd = (case IR.Node.kind nd
91                   of IR.COND{cond as ref x, ...} =>                   of IR.COND{cond as ref x, ...} =>
92                        if changed x                        if changed x
# Line 197  Line 199 
199                   in                   in
200                     if List.all (fn vn' => IR.Var.same(vn, vn')) vns                     if List.all (fn vn' => IR.Var.same(vn, vn')) vns
201                       then ((* a meaningless phi node; map y to vn *)                       then ((* a meaningless phi node; map y to vn *)
202  (* DEBUG ** Log.msg["** meaningless phi node: ", IR.phiToString (y, xs), "\n"]; *)  (* DEBUG ** Log.msg["** meaningless phi node: ", IR.phiToString (y, xs), "\n"]; **)
203                         ST.tick cntMeaninglessPhi;                         ST.tick cntMeaninglessPhi;
204                         List.app (Option.app decUse) xs;                         List.app (Option.app decUse) (List.tl xs);
205                         setVN(y, vn);                         setVN(y, vn);
206                         (env, phis))                         (env, phis))
207                       else let                       else let
# Line 207  Line 209 
209                         in                         in
210                           case expToVN(env, exp)                           case expToVN(env, exp)
211                            of SOME vn' => ((* a redundant phi node *)                            of SOME vn' => ((* a redundant phi node *)
212  (* DEBUG ** Log.msg["** redundant phi node: ", IR.phiToString (y, xs), "\n"]; *)  (* DEBUG ** Log.msg["** redundant phi node: ", IR.phiToString (y, xs), "\n"]; **)
213                                 ST.tick cntRedundantPhi;                                 ST.tick cntRedundantPhi;
214                                 List.app (Option.app decUse) xs;                                 List.app (Option.app decUse) xs;
215                                 setVN(y, vn');                                 setVN(y, vn');
# Line 224  Line 226 
226            fun vn (env, nd) = let            fun vn (env, nd) = let
227                  val env = (case IR.Node.kind nd                  val env = (case IR.Node.kind nd
228                         of IR.JOIN{phis, ...} => let                         of IR.JOIN{phis, ...} => let
229    (* FIXME: the processing of phi nodes in a JOIN should happen _after_ we have finished
230     * value numbering!  See tests/vis12-bugs/bug047.diderot for an example of where this
231     * goes wrong.
232     *)
233                              val (env, remainingPhis) = List.foldr doPhi (env, []) (!phis)                              val (env, remainingPhis) = List.foldr doPhi (env, []) (!phis)
234                              in                              in
235                                phis := remainingPhis;                                phis := remainingPhis;

Legend:
Removed from v.4402  
changed lines
  Added in v.4403

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0