Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java @ 19512:caad3adc5fde
Change forward ends to type EndNode and not AbstractEndNode.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 19 Feb 2015 21:06:37 +0100 |
parents | 5779b6771043 |
children | 3446ae32a2d8 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19095
diff
changeset
|
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.nodes; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
5206
dfe925845cad
Improve exacuation of anchored values, use it to fix if and merge simplifications
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5061
diff
changeset
|
25 import static com.oracle.graal.graph.iterators.NodePredicates.*; |
dfe925845cad
Improve exacuation of anchored values, use it to fix if and merge simplifications
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5061
diff
changeset
|
26 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 import java.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 |
17200
56458afc02a3
Use common nodes for integer and floating point arithmetic.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
29 import com.oracle.graal.compiler.common.type.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
30 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.graph.iterators.*; |
11881
da9db8331658
moved Canonicalizable and Simplifiable to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11631
diff
changeset
|
32 import com.oracle.graal.graph.spi.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16811
diff
changeset
|
33 import com.oracle.graal.nodeinfo.*; |
16039
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
34 import com.oracle.graal.nodes.calc.*; |
9646
183d33c76419
Removed ValueNode.dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9644
diff
changeset
|
35 import com.oracle.graal.nodes.extended.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
36 import com.oracle.graal.nodes.spi.*; |
13792
9e7acc9cad8e
kill unused frame states when loop exits are removed
Andreas Woess <andreas.woess@jku.at>
parents:
11881
diff
changeset
|
37 import com.oracle.graal.nodes.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 |
16811
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16332
diff
changeset
|
39 @NodeInfo |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19095
diff
changeset
|
40 public final class LoopBeginNode extends AbstractMergeNode implements IterableNodeType, LIRLowerable { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 |
19410
61d3cb8e1280
Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19403
diff
changeset
|
42 public static final NodeClass<LoopBeginNode> TYPE = NodeClass.get(LoopBeginNode.class); |
17276
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17200
diff
changeset
|
43 protected double loopFrequency; |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17200
diff
changeset
|
44 protected int nextEndIndex; |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17200
diff
changeset
|
45 protected int unswitches; |
19423
b0c1056a0842
Temporarily add inversion count to LoopBegin
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19410
diff
changeset
|
46 protected int inversionCount; |
b0c1056a0842
Temporarily add inversion count to LoopBegin
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19410
diff
changeset
|
47 |
16897
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
48 @OptionalInput(InputType.Guard) GuardingNode overflowGuard; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
50 public LoopBeginNode() { |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19095
diff
changeset
|
51 super(TYPE); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 loopFrequency = 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 public double loopFrequency() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 return loopFrequency; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 public void setLoopFrequency(double loopFrequency) { |
11463
93c63975217e
Make ComputeProbabilityClosure more robust to probabilities that to infinity because of loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9646
diff
changeset
|
60 assert loopFrequency >= 0; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 this.loopFrequency = loopFrequency; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 |
6667
e54aeb000ad7
Directly return the NodeSuccessorList in ControlSplitNode.blockSuccessors instead of creating a new Iterable
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6318
diff
changeset
|
64 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6667
diff
changeset
|
65 * Returns the <b>unordered</b> set of {@link LoopEndNode} that correspond to back-edges for |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6667
diff
changeset
|
66 * this loop. The order of the back-edges is unspecified, if you need to get an ordering |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6667
diff
changeset
|
67 * compatible for {@link PhiNode} creation, use {@link #orderedLoopEnds()}. |
15001 | 68 * |
6667
e54aeb000ad7
Directly return the NodeSuccessorList in ControlSplitNode.blockSuccessors instead of creating a new Iterable
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6318
diff
changeset
|
69 * @return the set of {@code LoopEndNode} that correspond to back-edges for this loop |
e54aeb000ad7
Directly return the NodeSuccessorList in ControlSplitNode.blockSuccessors instead of creating a new Iterable
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6318
diff
changeset
|
70 */ |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
71 public NodeIterable<LoopEndNode> loopEnds() { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
72 return usages().filter(LoopEndNode.class); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
73 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
74 |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5206
diff
changeset
|
75 public NodeIterable<LoopExitNode> loopExits() { |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5206
diff
changeset
|
76 return usages().filter(LoopExitNode.class); |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5206
diff
changeset
|
77 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5206
diff
changeset
|
78 |
5206
dfe925845cad
Improve exacuation of anchored values, use it to fix if and merge simplifications
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5061
diff
changeset
|
79 @Override |
dfe925845cad
Improve exacuation of anchored values, use it to fix if and merge simplifications
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5061
diff
changeset
|
80 public NodeIterable<Node> anchored() { |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5206
diff
changeset
|
81 return super.anchored().filter(isNotA(LoopEndNode.class).nor(LoopExitNode.class)); |
5206
dfe925845cad
Improve exacuation of anchored values, use it to fix if and merge simplifications
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5061
diff
changeset
|
82 } |
dfe925845cad
Improve exacuation of anchored values, use it to fix if and merge simplifications
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5061
diff
changeset
|
83 |
6667
e54aeb000ad7
Directly return the NodeSuccessorList in ControlSplitNode.blockSuccessors instead of creating a new Iterable
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6318
diff
changeset
|
84 /** |
19095
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
85 * Returns the set of {@link LoopEndNode} that correspond to back-edges for this loop, in |
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
86 * increasing {@link #phiPredecessorIndex} order. This method is suited to create new loop |
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
87 * {@link PhiNode}.<br> |
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
88 * |
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
89 * For example a new PhiNode may be added as follow: |
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
90 * |
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
91 * <pre> |
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
92 * PhiNode phi = new ValuePhiNode(stamp, loop); |
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
93 * phi.addInput(forwardEdgeValue); |
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
94 * for (LoopEndNode loopEnd : loop.orderedLoopEnds()) { |
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
95 * phi.addInput(backEdgeValue(loopEnd)); |
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
96 * } |
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
97 * </pre> |
15001 | 98 * |
6667
e54aeb000ad7
Directly return the NodeSuccessorList in ControlSplitNode.blockSuccessors instead of creating a new Iterable
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6318
diff
changeset
|
99 * @return the set of {@code LoopEndNode} that correspond to back-edges for this loop |
e54aeb000ad7
Directly return the NodeSuccessorList in ControlSplitNode.blockSuccessors instead of creating a new Iterable
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6318
diff
changeset
|
100 */ |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
101 public List<LoopEndNode> orderedLoopEnds() { |
5206
dfe925845cad
Improve exacuation of anchored values, use it to fix if and merge simplifications
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5061
diff
changeset
|
102 List<LoopEndNode> snapshot = loopEnds().snapshot(); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
103 Collections.sort(snapshot, new Comparator<LoopEndNode>() { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6667
diff
changeset
|
104 |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
105 @Override |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
106 public int compare(LoopEndNode o1, LoopEndNode o2) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
107 return o1.endIndex() - o2.endIndex(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
108 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
109 }); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
110 return snapshot; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
111 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
112 |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
113 public AbstractEndNode forwardEnd() { |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
114 assert forwardEndCount() == 1; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
115 return forwardEndAt(0); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 @Override |
14950
d5a1206e1923
NodeLIRBuilderTool: fix typo in interface name.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
119 public void generate(NodeLIRBuilderTool gen) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 // Nothing to emit, since this is node is used for structural purposes only. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 @Override |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
124 protected void deleteEnd(AbstractEndNode end) { |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
125 if (end instanceof LoopEndNode) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
126 LoopEndNode loopEnd = (LoopEndNode) end; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
127 loopEnd.setLoopBegin(null); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
128 int idx = loopEnd.endIndex(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
129 for (LoopEndNode le : loopEnds()) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
130 int leIdx = le.endIndex(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
131 assert leIdx != idx; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
132 if (leIdx > idx) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
133 le.setEndIndex(leIdx - 1); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
134 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
135 } |
4617
113d66f7454d
Add merge-before-loopend simplification for merges
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
136 nextEndIndex--; |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
137 } else { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
138 super.deleteEnd(end); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
139 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
140 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
141 |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
142 @Override |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 public int phiPredecessorCount() { |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
144 return forwardEndCount() + loopEnds().count(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
145 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
146 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 @Override |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
148 public int phiPredecessorIndex(AbstractEndNode pred) { |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
149 if (pred instanceof LoopEndNode) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
150 LoopEndNode loopEnd = (LoopEndNode) pred; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
151 if (loopEnd.loopBegin() == this) { |
4617
113d66f7454d
Add merge-before-loopend simplification for merges
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
152 assert loopEnd.endIndex() < loopEnds().count() : "Invalid endIndex : " + loopEnd; |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
153 return loopEnd.endIndex() + forwardEndCount(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
154 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
155 } else { |
19512
caad3adc5fde
Change forward ends to type EndNode and not AbstractEndNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19424
diff
changeset
|
156 return super.forwardEndIndex((EndNode) pred); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
157 } |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5210
diff
changeset
|
158 throw ValueNodeUtil.shouldNotReachHere("unknown pred : " + pred); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 @Override |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
162 public AbstractEndNode phiPredecessorAt(int index) { |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
163 if (index < forwardEndCount()) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
164 return forwardEndAt(index); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
165 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
166 for (LoopEndNode end : loopEnds()) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
167 int idx = index - forwardEndCount(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
168 assert idx >= 0; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
169 if (end.endIndex() == idx) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
170 return end; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
171 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 } |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5210
diff
changeset
|
173 throw ValueNodeUtil.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
174 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
175 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
176 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
177 public boolean verify() { |
4619
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4617
diff
changeset
|
178 assertTrue(loopEnds().isNotEmpty(), "missing loopEnd"); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 return super.verify(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 |
19095
9865883b5114
Improve javadoc around LoopEndNode's endIndex. Make related methods package-private.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18995
diff
changeset
|
182 int nextEndIndex() { |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
183 return nextEndIndex++; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
184 } |
4617
113d66f7454d
Add merge-before-loopend simplification for merges
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
185 |
6309
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
186 public int unswitches() { |
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
187 return unswitches; |
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
188 } |
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
189 |
19424
5779b6771043
Increment unswitch count after unswitching
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19423
diff
changeset
|
190 public void incrementUnswitches() { |
6309
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
191 unswitches++; |
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
192 } |
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
193 |
19423
b0c1056a0842
Temporarily add inversion count to LoopBegin
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19410
diff
changeset
|
194 public int getInversionCount() { |
b0c1056a0842
Temporarily add inversion count to LoopBegin
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19410
diff
changeset
|
195 return inversionCount; |
b0c1056a0842
Temporarily add inversion count to LoopBegin
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19410
diff
changeset
|
196 } |
b0c1056a0842
Temporarily add inversion count to LoopBegin
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19410
diff
changeset
|
197 |
b0c1056a0842
Temporarily add inversion count to LoopBegin
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19410
diff
changeset
|
198 public void setInversionCount(int count) { |
b0c1056a0842
Temporarily add inversion count to LoopBegin
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19410
diff
changeset
|
199 inversionCount = count; |
b0c1056a0842
Temporarily add inversion count to LoopBegin
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19410
diff
changeset
|
200 } |
b0c1056a0842
Temporarily add inversion count to LoopBegin
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19410
diff
changeset
|
201 |
4617
113d66f7454d
Add merge-before-loopend simplification for merges
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
202 @Override |
113d66f7454d
Add merge-before-loopend simplification for merges
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
203 public void simplify(SimplifierTool tool) { |
16039
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
204 removeDeadPhis(); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
205 canonicalizePhis(tool); |
4617
113d66f7454d
Add merge-before-loopend simplification for merges
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
206 } |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5547
diff
changeset
|
207 |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
208 public boolean isLoopExit(AbstractBeginNode begin) { |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5547
diff
changeset
|
209 return begin instanceof LoopExitNode && ((LoopExitNode) begin).loopBegin() == this; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5547
diff
changeset
|
210 } |
6318
8886fdfde36c
Factor out code that kills loop exits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6309
diff
changeset
|
211 |
8886fdfde36c
Factor out code that kills loop exits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6309
diff
changeset
|
212 public void removeExits() { |
8886fdfde36c
Factor out code that kills loop exits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6309
diff
changeset
|
213 for (LoopExitNode loopexit : loopExits().snapshot()) { |
8886fdfde36c
Factor out code that kills loop exits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6309
diff
changeset
|
214 loopexit.removeProxies(); |
16897
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
215 FrameState loopStateAfter = loopexit.stateAfter(); |
18994
8b4ef818169c
Make AbstractBeginNode an abstract class and create concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18993
diff
changeset
|
216 graph().replaceFixedWithFixed(loopexit, graph().add(new BeginNode())); |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
217 if (loopStateAfter != null && loopStateAfter.isAlive() && loopStateAfter.hasNoUsages()) { |
16897
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
218 GraphUtil.killWithUnusedFloatingInputs(loopStateAfter); |
13792
9e7acc9cad8e
kill unused frame states when loop exits are removed
Andreas Woess <andreas.woess@jku.at>
parents:
11881
diff
changeset
|
219 } |
6318
8886fdfde36c
Factor out code that kills loop exits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6309
diff
changeset
|
220 } |
8886fdfde36c
Factor out code that kills loop exits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6309
diff
changeset
|
221 } |
9644
a230bfbd9497
Use specialized node inputs for loopbegin's overflow check and for value anchor's anchored values
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
222 |
9646
183d33c76419
Removed ValueNode.dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9644
diff
changeset
|
223 public GuardingNode getOverflowGuard() { |
9644
a230bfbd9497
Use specialized node inputs for loopbegin's overflow check and for value anchor's anchored values
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
224 return overflowGuard; |
a230bfbd9497
Use specialized node inputs for loopbegin's overflow check and for value anchor's anchored values
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
225 } |
a230bfbd9497
Use specialized node inputs for loopbegin's overflow check and for value anchor's anchored values
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
226 |
9646
183d33c76419
Removed ValueNode.dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9644
diff
changeset
|
227 public void setOverflowGuard(GuardingNode overflowGuard) { |
15007
9a73164832a9
add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
228 updateUsagesInterface(this.overflowGuard, overflowGuard); |
9644
a230bfbd9497
Use specialized node inputs for loopbegin's overflow check and for value anchor's anchored values
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
229 this.overflowGuard = overflowGuard; |
a230bfbd9497
Use specialized node inputs for loopbegin's overflow check and for value anchor's anchored values
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
230 } |
15141
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
231 |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
232 /** |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
233 * Removes dead {@linkplain PhiNode phi nodes} hanging from this node. |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
234 * |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
235 * This method uses the heuristic that any node which not a phi node of this LoopBeginNode is |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
236 * alive. This allows the removal of dead phi loops. |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
237 */ |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
238 public void removeDeadPhis() { |
16039
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
239 if (phis().isNotEmpty()) { |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
240 Set<PhiNode> alive = Node.newSet(); |
16039
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
241 for (PhiNode phi : phis()) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
242 NodePredicate isAlive = u -> !isPhiAtMerge(u) || alive.contains(u); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
243 if (phi.usages().filter(isAlive).isNotEmpty()) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
244 alive.add(phi); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
245 for (PhiNode keptAlive : phi.values().filter(PhiNode.class).filter(isAlive.negate())) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
246 alive.add(keptAlive); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
247 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
248 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
249 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
250 for (PhiNode phi : phis().filter(((NodePredicate) alive::contains).negate()).snapshot()) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
251 phi.replaceAtUsages(null); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
252 phi.safeDelete(); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
253 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
254 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
255 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
256 |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
257 private static final int NO_INCREMENT = Integer.MIN_VALUE; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
258 |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
259 /** |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
260 * Returns an array with one entry for each input of the phi, which is either |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
261 * {@link #NO_INCREMENT} or the increment, i.e., the value by which the phi is incremented in |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
262 * the corresponding branch. |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
263 */ |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
264 private static int[] getSelfIncrements(PhiNode phi) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
265 int[] selfIncrement = new int[phi.valueCount()]; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
266 for (int i = 0; i < phi.valueCount(); i++) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
267 ValueNode input = phi.valueAt(i); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
268 long increment = NO_INCREMENT; |
17200
56458afc02a3
Use common nodes for integer and floating point arithmetic.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
269 if (input != null && input instanceof AddNode && input.stamp() instanceof IntegerStamp) { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
16919
diff
changeset
|
270 AddNode add = (AddNode) input; |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16157
diff
changeset
|
271 if (add.getX() == phi && add.getY().isConstant()) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17450
diff
changeset
|
272 increment = add.getY().asJavaConstant().asLong(); |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16157
diff
changeset
|
273 } else if (add.getY() == phi && add.getX().isConstant()) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17450
diff
changeset
|
274 increment = add.getX().asJavaConstant().asLong(); |
16039
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
275 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
276 } else if (input == phi) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
277 increment = 0; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
278 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
279 if (increment < Integer.MIN_VALUE || increment > Integer.MAX_VALUE || increment == NO_INCREMENT) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
280 increment = NO_INCREMENT; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
281 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
282 selfIncrement[i] = (int) increment; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
283 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
284 return selfIncrement; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
285 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
286 |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
287 /** |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
288 * Coalesces loop phis that represent the same value (which is not handled by normal Global |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
289 * Value Numbering). |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
290 */ |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
291 public void canonicalizePhis(SimplifierTool tool) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
292 int phiCount = phis().count(); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
293 if (phiCount > 1) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
294 int phiInputCount = phiPredecessorCount(); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
295 int phiIndex = 0; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
296 int[][] selfIncrement = new int[phiCount][]; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
297 PhiNode[] phis = this.phis().snapshot().toArray(new PhiNode[phiCount]); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
298 |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
299 for (phiIndex = 0; phiIndex < phiCount; phiIndex++) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
300 PhiNode phi = phis[phiIndex]; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
301 if (phi != null) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
302 nextPhi: for (int otherPhiIndex = phiIndex + 1; otherPhiIndex < phiCount; otherPhiIndex++) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
303 PhiNode otherPhi = phis[otherPhiIndex]; |
17276
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17200
diff
changeset
|
304 if (otherPhi == null || phi.getNodeClass() != otherPhi.getNodeClass() || !phi.valueEquals(otherPhi)) { |
16039
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
305 continue nextPhi; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
306 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
307 if (selfIncrement[phiIndex] == null) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
308 selfIncrement[phiIndex] = getSelfIncrements(phi); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
309 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
310 if (selfIncrement[otherPhiIndex] == null) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
311 selfIncrement[otherPhiIndex] = getSelfIncrements(otherPhi); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
312 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
313 int[] phiIncrement = selfIncrement[phiIndex]; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
314 int[] otherPhiIncrement = selfIncrement[otherPhiIndex]; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
315 for (int inputIndex = 0; inputIndex < phiInputCount; inputIndex++) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
316 if (phiIncrement[inputIndex] == NO_INCREMENT) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
317 if (phi.valueAt(inputIndex) != otherPhi.valueAt(inputIndex)) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
318 continue nextPhi; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
319 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
320 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
321 if (phiIncrement[inputIndex] != otherPhiIncrement[inputIndex]) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
322 continue nextPhi; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
323 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
324 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
325 if (tool != null) { |
16157
bd1202138e21
add SimplifierTool.addToWorkList for Iterable<Node>
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16039
diff
changeset
|
326 tool.addToWorkList(otherPhi.usages()); |
16039
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
327 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
328 otherPhi.replaceAtUsages(phi); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
329 GraphUtil.killWithUnusedFloatingInputs(otherPhi); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
330 phis[otherPhiIndex] = null; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
331 } |
15141
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
332 } |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
333 } |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
334 } |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
335 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
336 } |