From: bdemsky Date: Wed, 24 Jun 2009 09:34:20 +0000 (+0000) Subject: improve propagation optimization X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c951b736cd2a3744c3af2410deb1929dc2800d6f;p=IRC.git improve propagation optimization --- diff --git a/Robust/src/Analysis/Loops/CopyPropagation.java b/Robust/src/Analysis/Loops/CopyPropagation.java index e151f82a..9d211cf9 100644 --- a/Robust/src/Analysis/Loops/CopyPropagation.java +++ b/Robust/src/Analysis/Loops/CopyPropagation.java @@ -18,44 +18,46 @@ public class CopyPropagation { do { changed=false; HashSet tovisit=new HashSet(); - HashSet discovered=new HashSet(); tovisit.add(fm); - discovered.add(fm); while(!tovisit.isEmpty()) { FlatNode fn=(FlatNode) tovisit.iterator().next(); tovisit.remove(fn); - for(int i=0;i tab; if (fn.numPrev()>=1&&table.containsKey(fn.getPrev(0))) tab=new Hashtable(table.get(fn.getPrev(0))); else tab=new Hashtable(); //Compute intersection + + HashSet toremove=new HashSet(); for(int i=1;i tp=table.get(fn.getPrev(i)); for(Iterator tmpit=tab.entrySet().iterator();tmpit.hasNext();) { Map.Entry t=(Map.Entry)tmpit.next(); TempDescriptor tmp=(TempDescriptor)t.getKey(); - if (tp!=null&&(!tp.containsKey(tmp)||tp.get(tmp)!=tab.get(tmp))) { - tmpit.remove(); + if (tp!=null&&tp.containsKey(tmp)&&tp.get(tmp)!=tab.get(tmp)) { + toremove.add(tmp); } } } + TempDescriptor[]writes=fn.writesTemps(); for(int i=0;i tmpit=tab.keySet().iterator();tmpit.hasNext();) { TempDescriptor tmp2=tmpit.next(); if (tmp==tab.get(tmp2)) - tmpit.remove(); + toremove.add(tmp2); } } + + for(Iterator tmpit=toremove.iterator();tmpit.hasNext();) { + TempDescriptor tmp=tmpit.next(); + tab.put(tmp, bogustd); + } + if (fn.kind()==FKind.FlatOpNode) { FlatOpNode fon=(FlatOpNode)fn; if (fon.getOp().getOp()==Operation.ASSIGN) { @@ -70,7 +72,9 @@ public class CopyPropagation { tovisit.add(nnext); } } - } + } //end of dataflow while loop + + //do remapping step here for(Iterator it=fm.getNodeSet().iterator();it.hasNext();) { FlatNode fn=it.next(); Hashtable tab=table.get(fn); @@ -78,7 +82,7 @@ public class CopyPropagation { TempDescriptor[]reads=fn.readsTemps(); for(int i=0;i