Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java @ 18845:f57d86eb036f
removed Node factory methods
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Jan 2015 20:39:04 +0100 |
parents | 1518c3296cc8 |
children | ff232ff8d028 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
16039
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
2 * Copyright (c) 2011, 2014, 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 |
11631
1aed684853f6
refactored IterableNodeType into a top level type to avoid problems it was causing for javac and JDT (CR-1408)
Doug Simon <doug.simon@oracle.com>
parents:
11463
diff
changeset
|
40 public class LoopBeginNode extends MergeNode implements IterableNodeType, LIRLowerable { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 |
17276
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17200
diff
changeset
|
42 protected double loopFrequency; |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17200
diff
changeset
|
43 protected int nextEndIndex; |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17200
diff
changeset
|
44 protected int unswitches; |
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
|
45 @OptionalInput(InputType.Guard) GuardingNode overflowGuard; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
47 public LoopBeginNode() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 loopFrequency = 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 public double loopFrequency() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 return loopFrequency; |
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 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
|
56 assert loopFrequency >= 0; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 this.loopFrequency = loopFrequency; |
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 |
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
|
60 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6667
diff
changeset
|
61 * 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
|
62 * 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
|
63 * compatible for {@link PhiNode} creation, use {@link #orderedLoopEnds()}. |
15001 | 64 * |
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
|
65 * @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
|
66 */ |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
67 public NodeIterable<LoopEndNode> loopEnds() { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
68 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
|
69 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
70 |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5206
diff
changeset
|
71 public NodeIterable<LoopExitNode> loopExits() { |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5206
diff
changeset
|
72 return usages().filter(LoopExitNode.class); |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5206
diff
changeset
|
73 } |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5206
diff
changeset
|
74 |
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
|
75 @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
|
76 public NodeIterable<Node> anchored() { |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5206
diff
changeset
|
77 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
|
78 } |
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 |
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
|
80 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6667
diff
changeset
|
81 * Returns the set of {@link LoopEndNode} that correspond to back-edges for this loop, ordered |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6667
diff
changeset
|
82 * in increasing {@link #phiPredecessorIndex}. This method is suited to create new loop |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6667
diff
changeset
|
83 * {@link PhiNode}. |
15001 | 84 * |
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
|
85 * @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
|
86 */ |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
87 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
|
88 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
|
89 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
|
90 |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
91 @Override |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
92 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
|
93 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
|
94 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
95 }); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
96 return snapshot; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
97 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
98 |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
99 public AbstractEndNode forwardEnd() { |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
100 assert forwardEndCount() == 1; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
101 return forwardEndAt(0); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 @Override |
14950
d5a1206e1923
NodeLIRBuilderTool: fix typo in interface name.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
105 public void generate(NodeLIRBuilderTool gen) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 // 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
|
107 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 @Override |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
110 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
|
111 if (end instanceof LoopEndNode) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
112 LoopEndNode loopEnd = (LoopEndNode) end; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
113 loopEnd.setLoopBegin(null); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
114 int idx = loopEnd.endIndex(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
115 for (LoopEndNode le : loopEnds()) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
116 int leIdx = le.endIndex(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
117 assert leIdx != idx; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
118 if (leIdx > idx) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
119 le.setEndIndex(leIdx - 1); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
120 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
121 } |
4617
113d66f7454d
Add merge-before-loopend simplification for merges
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
122 nextEndIndex--; |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
123 } else { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
124 super.deleteEnd(end); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
125 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
126 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
127 |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
128 @Override |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 public int phiPredecessorCount() { |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
130 return forwardEndCount() + loopEnds().count(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
132 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 @Override |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
134 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
|
135 if (pred instanceof LoopEndNode) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
136 LoopEndNode loopEnd = (LoopEndNode) pred; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
137 if (loopEnd.loopBegin() == this) { |
4617
113d66f7454d
Add merge-before-loopend simplification for merges
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
138 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
|
139 return loopEnd.endIndex() + forwardEndCount(); |
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 } else { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
142 return super.forwardEndIndex(pred); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 } |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5210
diff
changeset
|
144 throw ValueNodeUtil.shouldNotReachHere("unknown pred : " + pred); |
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 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
|
149 if (index < forwardEndCount()) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
150 return forwardEndAt(index); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
151 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
152 for (LoopEndNode end : loopEnds()) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
153 int idx = index - forwardEndCount(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
154 assert idx >= 0; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
155 if (end.endIndex() == idx) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
156 return end; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
157 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 } |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5210
diff
changeset
|
159 throw ValueNodeUtil.shouldNotReachHere(); |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
162 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
163 public boolean verify() { |
4619
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4617
diff
changeset
|
164 assertTrue(loopEnds().isNotEmpty(), "missing loopEnd"); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 return super.verify(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
167 |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
168 public int nextEndIndex() { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
169 return nextEndIndex++; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
170 } |
4617
113d66f7454d
Add merge-before-loopend simplification for merges
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
171 |
6309
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
172 public int unswitches() { |
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
173 return unswitches; |
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
174 } |
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
175 |
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
176 public void incUnswitches() { |
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
177 unswitches++; |
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
178 } |
6f8b6fc03c96
Add a maximum number of unswitching per loop
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5813
diff
changeset
|
179 |
4617
113d66f7454d
Add merge-before-loopend simplification for merges
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
180 @Override |
113d66f7454d
Add merge-before-loopend simplification for merges
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
181 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
|
182 removeDeadPhis(); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
183 canonicalizePhis(tool); |
4617
113d66f7454d
Add merge-before-loopend simplification for merges
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
184 } |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5547
diff
changeset
|
185 |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15141
diff
changeset
|
186 public boolean isLoopExit(BeginNode begin) { |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5547
diff
changeset
|
187 return begin instanceof LoopExitNode && ((LoopExitNode) begin).loopBegin() == this; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5547
diff
changeset
|
188 } |
6318
8886fdfde36c
Factor out code that kills loop exits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6309
diff
changeset
|
189 |
8886fdfde36c
Factor out code that kills loop exits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6309
diff
changeset
|
190 public void removeExits() { |
8886fdfde36c
Factor out code that kills loop exits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6309
diff
changeset
|
191 for (LoopExitNode loopexit : loopExits().snapshot()) { |
8886fdfde36c
Factor out code that kills loop exits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6309
diff
changeset
|
192 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
|
193 FrameState loopStateAfter = loopexit.stateAfter(); |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
194 graph().replaceFixedWithFixed(loopexit, graph().add(new BeginNode())); |
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
|
195 if (loopStateAfter != null && loopStateAfter.isAlive() && loopStateAfter.usages().isEmpty()) { |
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
196 GraphUtil.killWithUnusedFloatingInputs(loopStateAfter); |
13792
9e7acc9cad8e
kill unused frame states when loop exits are removed
Andreas Woess <andreas.woess@jku.at>
parents:
11881
diff
changeset
|
197 } |
6318
8886fdfde36c
Factor out code that kills loop exits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6309
diff
changeset
|
198 } |
8886fdfde36c
Factor out code that kills loop exits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6309
diff
changeset
|
199 } |
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
|
200 |
9646
183d33c76419
Removed ValueNode.dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9644
diff
changeset
|
201 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
|
202 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
|
203 } |
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
|
204 |
9646
183d33c76419
Removed ValueNode.dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9644
diff
changeset
|
205 public void setOverflowGuard(GuardingNode overflowGuard) { |
15007
9a73164832a9
add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
206 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
|
207 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
|
208 } |
15141
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
209 |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
210 /** |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
211 * 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
|
212 * |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
213 * 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
|
214 * 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
|
215 */ |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
216 public void removeDeadPhis() { |
16039
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
217 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
|
218 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
|
219 for (PhiNode phi : phis()) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
220 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
|
221 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
|
222 alive.add(phi); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
223 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
|
224 alive.add(keptAlive); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
225 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
226 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
227 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
228 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
|
229 phi.replaceAtUsages(null); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
230 phi.safeDelete(); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
231 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
232 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
233 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
234 |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
235 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
|
236 |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
237 /** |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
238 * 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
|
239 * {@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
|
240 * the corresponding branch. |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
241 */ |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
242 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
|
243 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
|
244 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
|
245 ValueNode input = phi.valueAt(i); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
246 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
|
247 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
|
248 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
|
249 if (add.getX() == phi && add.getY().isConstant()) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17450
diff
changeset
|
250 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
|
251 } else if (add.getY() == phi && add.getX().isConstant()) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17450
diff
changeset
|
252 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
|
253 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
254 } else if (input == phi) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
255 increment = 0; |
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 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
|
258 increment = NO_INCREMENT; |
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 selfIncrement[i] = (int) increment; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
261 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
262 return selfIncrement; |
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 |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
265 /** |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
266 * 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
|
267 * Value Numbering). |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
268 */ |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
269 public void canonicalizePhis(SimplifierTool tool) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
270 int phiCount = phis().count(); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
271 if (phiCount > 1) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
272 int phiInputCount = phiPredecessorCount(); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
273 int phiIndex = 0; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
274 int[][] selfIncrement = new int[phiCount][]; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
275 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
|
276 |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
277 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
|
278 PhiNode phi = phis[phiIndex]; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
279 if (phi != null) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
280 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
|
281 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
|
282 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
|
283 continue nextPhi; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
284 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
285 if (selfIncrement[phiIndex] == null) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
286 selfIncrement[phiIndex] = getSelfIncrements(phi); |
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 if (selfIncrement[otherPhiIndex] == null) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
289 selfIncrement[otherPhiIndex] = getSelfIncrements(otherPhi); |
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 int[] phiIncrement = selfIncrement[phiIndex]; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
292 int[] otherPhiIncrement = selfIncrement[otherPhiIndex]; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
293 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
|
294 if (phiIncrement[inputIndex] == NO_INCREMENT) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
295 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
|
296 continue nextPhi; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
297 } |
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 if (phiIncrement[inputIndex] != otherPhiIncrement[inputIndex]) { |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
300 continue nextPhi; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
301 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
302 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
303 if (tool != null) { |
16157
bd1202138e21
add SimplifierTool.addToWorkList for Iterable<Node>
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16039
diff
changeset
|
304 tool.addToWorkList(otherPhi.usages()); |
16039
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
305 } |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
306 otherPhi.replaceAtUsages(phi); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
307 GraphUtil.killWithUnusedFloatingInputs(otherPhi); |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
308 phis[otherPhiIndex] = null; |
4c284376c374
remove dead and redundant phis during LoopBeginNode simplification
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15145
diff
changeset
|
309 } |
15141
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
310 } |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
311 } |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
312 } |
6f132c0219e9
Remove dead phi loops during loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15007
diff
changeset
|
313 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
314 } |