Mercurial > hg > truffle
comparison graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopEx.java @ 5675:776366f3a41a
A bit of work on counted loops
Introduce FullUnroll phase before EscapeAnalysis
split Loop transforms into 2 phase : things that run before lowering, and things that run after lowering
Introduce Reassociate invariants after lowering
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Thu, 21 Jun 2012 16:35:23 +0200 |
parents | 9f3250602d69 |
children | 429accae15aa |
comparison
equal
deleted
inserted
replaced
5674:b5a53a04913c | 5675:776366f3a41a |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.graal.compiler.loop; | 23 package com.oracle.graal.compiler.loop; |
24 | 24 |
25 import com.oracle.graal.api.code.*; | |
26 import com.oracle.graal.api.meta.*; | |
27 import com.oracle.graal.debug.*; | |
25 import com.oracle.graal.graph.*; | 28 import com.oracle.graal.graph.*; |
29 import com.oracle.graal.graph.iterators.*; | |
26 import com.oracle.graal.lir.cfg.*; | 30 import com.oracle.graal.lir.cfg.*; |
27 import com.oracle.graal.nodes.*; | 31 import com.oracle.graal.nodes.*; |
32 import com.oracle.graal.nodes.calc.*; | |
28 | 33 |
29 public class LoopEx { | 34 public class LoopEx { |
30 private final Loop lirLoop; | 35 private final Loop lirLoop; |
31 private LoopFragmentInside inside; | 36 private LoopFragmentInside inside; |
32 private LoopFragmentWhole whole; | 37 private LoopFragmentWhole whole; |
103 return whole().nodes().count(); | 108 return whole().nodes().count(); |
104 } | 109 } |
105 | 110 |
106 @Override | 111 @Override |
107 public String toString() { | 112 public String toString() { |
108 return isCounted() ? "Counted" : "" + "Loop (depth=" + lirLoop().depth + ") " + loopBegin(); | 113 return (isCounted() ? "CountedLoop [" + counted() + "] " : "Loop ") + "(depth=" + lirLoop().depth + ") " + loopBegin(); |
114 } | |
115 | |
116 private class InvariantPredicate extends NodePredicate { | |
117 @Override | |
118 public boolean apply(Node n) { | |
119 return isOutsideLoop(n); | |
120 } | |
121 } | |
122 | |
123 public void reassociateInvariants() { | |
124 InvariantPredicate invariant = new InvariantPredicate(); | |
125 StructuredGraph graph = (StructuredGraph) loopBegin().graph(); | |
126 for (BinaryNode binary : whole().nodes().filter(BinaryNode.class)) { | |
127 if (!BinaryNode.canTryReassociate(binary)) { | |
128 continue; | |
129 } | |
130 BinaryNode result = BinaryNode.reassociate(binary, invariant); | |
131 if (result != binary) { | |
132 Debug.log(CodeUtil.format("%H::%n", Debug.contextLookup(ResolvedJavaMethod.class)) + " : Reassociated %s into %s", binary, result); | |
133 graph.replaceFloating(binary, result); | |
134 } | |
135 } | |
136 } | |
137 | |
138 public void setCounted(CountedLoopInfo countedLoopInfo) { | |
139 counted = countedLoopInfo; | |
109 } | 140 } |
110 } | 141 } |