Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java @ 7660:0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Fri, 01 Feb 2013 17:32:59 +0100 |
parents | 5e3d1a68664e |
children | 301cbb131b5d |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. |
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 |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
25 import java.util.*; |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
26 |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5504
diff
changeset
|
27 import com.oracle.graal.api.meta.*; |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
28 import com.oracle.graal.graph.*; |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6590
diff
changeset
|
29 import com.oracle.graal.graph.iterators.*; |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
30 import com.oracle.graal.nodes.PhiNode.PhiType; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
31 import com.oracle.graal.nodes.calc.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
32 import com.oracle.graal.nodes.spi.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
33 import com.oracle.graal.nodes.type.*; |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
34 import com.oracle.graal.nodes.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
37 * The {@code IfNode} represents a branch that can go one of two directions depending on the outcome |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
38 * of a comparison. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 */ |
5891
fd8832ae511d
removed artifacts of defunct type system
Lukas Stadler <lukas.stadler@jku.at>
parents:
5763
diff
changeset
|
40 public final class IfNode extends ControlSplitNode implements Simplifiable, LIRLowerable, Negatable { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
41 |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
42 @Successor private BeginNode trueSuccessor; |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
43 @Successor private BeginNode falseSuccessor; |
6563
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
44 @Input private BooleanNode condition; |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
45 private double trueSuccessorProbability; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 |
6563
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
47 public BooleanNode condition() { |
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
48 return condition; |
3733
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 |
6563
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
51 public void setCondition(BooleanNode x) { |
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
52 updateUsages(condition, x); |
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
53 condition = x; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5300
diff
changeset
|
54 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5300
diff
changeset
|
55 |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
56 public IfNode(BooleanNode condition, FixedNode trueSuccessor, FixedNode falseSuccessor, double trueSuccessorProbability) { |
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
57 this(condition, BeginNode.begin(trueSuccessor), BeginNode.begin(falseSuccessor), trueSuccessorProbability); |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
58 } |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
59 |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
60 public IfNode(BooleanNode condition, BeginNode trueSuccessor, BeginNode falseSuccessor, double trueSuccessorProbability) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
61 super(StampFactory.forVoid()); |
6563
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
62 this.condition = condition; |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
63 this.falseSuccessor = falseSuccessor; |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
64 this.trueSuccessorProbability = trueSuccessorProbability; |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
65 this.trueSuccessor = trueSuccessor; |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
66 |
5695
a63ed5993987
Add leadGraphID to IfNOde so that we can convert them to deopts
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5563
diff
changeset
|
67 } |
a63ed5993987
Add leadGraphID to IfNOde so that we can convert them to deopts
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5563
diff
changeset
|
68 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 * Gets the true successor. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
71 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 * @return the true successor |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 public BeginNode trueSuccessor() { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
75 return trueSuccessor; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 * Gets the false successor. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
80 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 * @return the false successor |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 public BeginNode falseSuccessor() { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
84 return falseSuccessor; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 public void setTrueSuccessor(BeginNode node) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
88 updatePredecessor(trueSuccessor, node); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
89 trueSuccessor = node; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 public void setFalseSuccessor(BeginNode node) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
93 updatePredecessor(falseSuccessor, node); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
94 falseSuccessor = node; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 * Gets the node corresponding to the specified outcome of the branch. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
99 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 * @param istrue {@code true} if the true successor is requested, {@code false} otherwise |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 * @return the corresponding successor |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 */ |
4338 | 103 public BeginNode successor(boolean istrue) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
104 return istrue ? trueSuccessor : falseSuccessor; |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
105 } |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
106 |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
107 @Override |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
108 public Negatable negate() { |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
109 BeginNode trueSucc = trueSuccessor(); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
110 BeginNode falseSucc = falseSuccessor(); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
111 setTrueSuccessor(null); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
112 setFalseSuccessor(null); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
113 setTrueSuccessor(falseSucc); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
114 setFalseSuccessor(trueSucc); |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
115 trueSuccessorProbability = 1 - trueSuccessorProbability; |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
116 return this; |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
117 } |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
118 |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
119 public void setTrueSuccessorProbability(double prob) { |
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
120 trueSuccessorProbability = prob; |
7368
f04a5e46cdd2
new facility to add branch probabilities for snippets, probabilities for frequently-used snippets
Lukas Stadler <lukas.stadler@jku.at>
parents:
7326
diff
changeset
|
121 } |
f04a5e46cdd2
new facility to add branch probabilities for snippets, probabilities for frequently-used snippets
Lukas Stadler <lukas.stadler@jku.at>
parents:
7326
diff
changeset
|
122 |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
123 @Override |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
124 public double probability(BeginNode successor) { |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
125 return successor == trueSuccessor ? trueSuccessorProbability : 1 - trueSuccessorProbability; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 public void generate(LIRGeneratorTool gen) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 gen.emitIf(this); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
134 public boolean verify() { |
6563
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
135 assertTrue(condition() != null, "missing condition"); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 assertTrue(trueSuccessor() != null, "missing trueSuccessor"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 assertTrue(falseSuccessor() != null, "missing falseSuccessor"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 return super.verify(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 @Override |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
142 public void simplify(SimplifierTool tool) { |
6563
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
143 if (condition() instanceof ConstantNode) { |
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
144 ConstantNode c = (ConstantNode) condition(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
145 if (c.asConstant().asBoolean()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
146 tool.deleteBranch(falseSuccessor()); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
147 tool.addToWorkList(trueSuccessor()); |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
148 ((StructuredGraph) graph()).removeSplit(this, trueSuccessor()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 tool.deleteBranch(trueSuccessor()); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
151 tool.addToWorkList(falseSuccessor()); |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
152 ((StructuredGraph) graph()).removeSplit(this, falseSuccessor()); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
153 } |
5293
2baec1384f2d
Do not remove empty diamond shape if there are guards in any of the branches and evacuate any other anchored values
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5206
diff
changeset
|
154 } else if (trueSuccessor().guards().isEmpty() && falseSuccessor().guards().isEmpty()) { |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
155 if (removeOrMaterializeIf(tool)) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
156 return; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
157 } else if (removeIntermediateMaterialization(tool)) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
158 return; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
159 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
160 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
161 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
162 |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
163 /** |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
164 * Tries to remove an empty if construct or replace an if construct with a materialization. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
165 * |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
166 * @return true if a transformation was made, false otherwise |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
167 */ |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
168 private boolean removeOrMaterializeIf(SimplifierTool tool) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
169 if (trueSuccessor().next() instanceof EndNode && falseSuccessor().next() instanceof EndNode) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
170 EndNode trueEnd = (EndNode) trueSuccessor().next(); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
171 EndNode falseEnd = (EndNode) falseSuccessor().next(); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
172 MergeNode merge = trueEnd.merge(); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
173 if (merge == falseEnd.merge() && merge.forwardEndCount() == 2 && trueSuccessor().anchored().isEmpty() && falseSuccessor().anchored().isEmpty()) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
174 Iterator<PhiNode> phis = merge.phis().iterator(); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
175 if (!phis.hasNext()) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
176 // empty if construct with no phis: remove it |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
177 removeEmptyIf(tool); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
178 return false; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
179 } else { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
180 PhiNode singlePhi = phis.next(); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
181 if (!phis.hasNext()) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
182 // one phi at the merge of an otherwise empty if construct: try to convert |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
183 // into a MaterializeNode |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
184 boolean inverted = trueEnd == merge.forwardEndAt(1); |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
185 ValueNode trueValue = singlePhi.valueAt(inverted ? 1 : 0); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
186 ValueNode falseValue = singlePhi.valueAt(inverted ? 0 : 1); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
187 if (trueValue.kind() != falseValue.kind()) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
188 return false; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
189 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
190 if (trueValue.kind() != Kind.Int && trueValue.kind() != Kind.Long) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
191 return false; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
192 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
193 if (trueValue.isConstant() && falseValue.isConstant()) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
194 MaterializeNode materialize = MaterializeNode.create(condition(), trueValue, falseValue); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
195 ((StructuredGraph) graph()).replaceFloating(singlePhi, materialize); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
196 removeEmptyIf(tool); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
197 return true; |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
198 } |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
199 } |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
200 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
201 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
202 } |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
203 return false; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
204 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
205 |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
206 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
207 * Tries to connect code that initializes a variable directly with the successors of an if |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
208 * construct that switches on the variable. For example, the pseudo code below: |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
209 * |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
210 * <pre> |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
211 * contains(list, e, yes, no) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
212 * if (list == null || e == null) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
213 * condition = false; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
214 * } else { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
215 * condition = false; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
216 * for (i in list) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
217 * if (i.equals(e)) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
218 * condition = true; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
219 * break; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
220 * } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
221 * } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
222 * } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
223 * if (condition) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
224 * return yes; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
225 * } else { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
226 * return no; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
227 * } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
228 * } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
229 * </pre> |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
230 * |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
231 * will be transformed into: |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
232 * |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
233 * <pre> |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
234 * contains(list, e, yes, no) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
235 * if (list == null || e == null) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
236 * return no; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
237 * } else { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
238 * condition = false; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
239 * for (i in list) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
240 * if (i.equals(e)) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
241 * return yes; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
242 * } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
243 * } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
244 * return no; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
245 * } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
246 * } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
247 * </pre> |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
248 * |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
249 * @return true if a transformation was made, false otherwise |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
250 */ |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
251 private boolean removeIntermediateMaterialization(SimplifierTool tool) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
252 if (!(condition() instanceof CompareNode)) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
253 return false; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
254 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
255 |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
256 CompareNode compare = (CompareNode) condition(); |
6585
5c1787a0be00
removing intermediate materializations is disabled when the compare input to an if has more than one usage
Doug Simon <doug.simon@oracle.com>
parents:
6583
diff
changeset
|
257 if (compare.usages().count() != 1) { |
5c1787a0be00
removing intermediate materializations is disabled when the compare input to an if has more than one usage
Doug Simon <doug.simon@oracle.com>
parents:
6583
diff
changeset
|
258 return false; |
5c1787a0be00
removing intermediate materializations is disabled when the compare input to an if has more than one usage
Doug Simon <doug.simon@oracle.com>
parents:
6583
diff
changeset
|
259 } |
5c1787a0be00
removing intermediate materializations is disabled when the compare input to an if has more than one usage
Doug Simon <doug.simon@oracle.com>
parents:
6583
diff
changeset
|
260 |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
261 if (!(predecessor() instanceof MergeNode)) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
262 return false; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
263 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
264 |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
265 MergeNode merge = (MergeNode) predecessor(); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
266 if (!merge.anchored().isEmpty()) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
267 return false; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
268 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
269 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
270 // Only consider merges with a single usage that is both a phi and an operand of the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
271 // comparison |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6590
diff
changeset
|
272 NodeIterable<Node> mergeUsages = merge.usages(); |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
273 if (mergeUsages.count() != 1) { |
6577
f170a0d2b3b9
disabled IfNode materialization simplification if associated merge has a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6575
diff
changeset
|
274 return false; |
f170a0d2b3b9
disabled IfNode materialization simplification if associated merge has a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6575
diff
changeset
|
275 } |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
276 Node singleUsage = mergeUsages.first(); |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
277 if (!(singleUsage instanceof PhiNode) || (singleUsage != compare.x() && singleUsage != compare.y())) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
278 return false; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
279 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
280 |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
281 // Ensure phi is used by at most the comparison and the merge's frame state (if any) |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
282 PhiNode phi = (PhiNode) singleUsage; |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6590
diff
changeset
|
283 NodeIterable<Node> phiUsages = phi.usages(); |
6590
dc5eec61daba
removing intermediate materialization with frame-state-full merges now works
Doug Simon <doug.simon@oracle.com>
parents:
6586
diff
changeset
|
284 if (phiUsages.count() > 2) { |
dc5eec61daba
removing intermediate materialization with frame-state-full merges now works
Doug Simon <doug.simon@oracle.com>
parents:
6586
diff
changeset
|
285 return false; |
dc5eec61daba
removing intermediate materialization with frame-state-full merges now works
Doug Simon <doug.simon@oracle.com>
parents:
6586
diff
changeset
|
286 } |
dc5eec61daba
removing intermediate materialization with frame-state-full merges now works
Doug Simon <doug.simon@oracle.com>
parents:
6586
diff
changeset
|
287 for (Node usage : phiUsages) { |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
288 if (usage != compare && usage != merge.stateAfter()) { |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
289 return false; |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
290 } |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
291 } |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
292 |
6590
dc5eec61daba
removing intermediate materialization with frame-state-full merges now works
Doug Simon <doug.simon@oracle.com>
parents:
6586
diff
changeset
|
293 List<EndNode> mergePredecessors = merge.cfgPredecessors().snapshot(); |
dc5eec61daba
removing intermediate materialization with frame-state-full merges now works
Doug Simon <doug.simon@oracle.com>
parents:
6586
diff
changeset
|
294 if (phi.valueCount() != merge.forwardEndCount()) { |
dc5eec61daba
removing intermediate materialization with frame-state-full merges now works
Doug Simon <doug.simon@oracle.com>
parents:
6586
diff
changeset
|
295 // Handles a loop begin merge |
dc5eec61daba
removing intermediate materialization with frame-state-full merges now works
Doug Simon <doug.simon@oracle.com>
parents:
6586
diff
changeset
|
296 return false; |
dc5eec61daba
removing intermediate materialization with frame-state-full merges now works
Doug Simon <doug.simon@oracle.com>
parents:
6586
diff
changeset
|
297 } |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
298 |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
299 Constant[] xs = constantValues(compare.x(), merge); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
300 Constant[] ys = constantValues(compare.y(), merge); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
301 if (xs == null || ys == null) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
302 return false; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
303 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
304 |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
305 List<EndNode> falseEnds = new ArrayList<>(mergePredecessors.size()); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
306 List<EndNode> trueEnds = new ArrayList<>(mergePredecessors.size()); |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
307 Map<EndNode, ValueNode> phiValues = new HashMap<>(mergePredecessors.size()); |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
308 |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
309 BeginNode oldFalseSuccessor = falseSuccessor(); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
310 BeginNode oldTrueSuccessor = trueSuccessor(); |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
311 |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
312 setFalseSuccessor(null); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
313 setTrueSuccessor(null); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
314 |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
315 Iterator<EndNode> ends = mergePredecessors.iterator(); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
316 for (int i = 0; i < xs.length; i++) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
317 EndNode end = ends.next(); |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
318 phiValues.put(end, phi.valueAt(end)); |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
319 if (compare.condition().foldCondition(xs[i], ys[i], tool.runtime(), compare.unorderedIsTrue())) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
320 trueEnds.add(end); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
321 } else { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
322 falseEnds.add(end); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
323 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
324 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
325 assert !ends.hasNext(); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
326 |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
327 connectEnds(falseEnds, phiValues, oldFalseSuccessor, merge, tool); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
328 connectEnds(trueEnds, phiValues, oldTrueSuccessor, merge, tool); |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
329 |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
330 GraphUtil.killCFG(merge); |
6585
5c1787a0be00
removing intermediate materializations is disabled when the compare input to an if has more than one usage
Doug Simon <doug.simon@oracle.com>
parents:
6583
diff
changeset
|
331 |
5c1787a0be00
removing intermediate materializations is disabled when the compare input to an if has more than one usage
Doug Simon <doug.simon@oracle.com>
parents:
6583
diff
changeset
|
332 assert !merge.isAlive() : merge; |
5c1787a0be00
removing intermediate materializations is disabled when the compare input to an if has more than one usage
Doug Simon <doug.simon@oracle.com>
parents:
6583
diff
changeset
|
333 assert !phi.isAlive() : phi; |
5c1787a0be00
removing intermediate materializations is disabled when the compare input to an if has more than one usage
Doug Simon <doug.simon@oracle.com>
parents:
6583
diff
changeset
|
334 assert !compare.isAlive() : compare; |
5c1787a0be00
removing intermediate materializations is disabled when the compare input to an if has more than one usage
Doug Simon <doug.simon@oracle.com>
parents:
6583
diff
changeset
|
335 assert !this.isAlive() : this; |
5c1787a0be00
removing intermediate materializations is disabled when the compare input to an if has more than one usage
Doug Simon <doug.simon@oracle.com>
parents:
6583
diff
changeset
|
336 |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
337 return true; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
338 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
339 |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
340 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
341 * Connects a set of ends to a given successor, inserting a merge node if there is more than one |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
342 * end. If {@code ends} is empty, then {@code successor} is |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
343 * {@linkplain GraphUtil#killCFG(FixedNode) killed} otherwise it is added to {@code tool}'s |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
344 * {@linkplain SimplifierTool#addToWorkList(com.oracle.graal.graph.Node) work list}. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
345 * |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
346 * @param oldMerge the merge being removed |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
347 * @param phiValues the values of the phi at the merge, keyed by the merge ends |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
348 */ |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
349 private void connectEnds(List<EndNode> ends, Map<EndNode, ValueNode> phiValues, BeginNode successor, MergeNode oldMerge, SimplifierTool tool) { |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
350 if (ends.isEmpty()) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
351 GraphUtil.killCFG(successor); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
352 } else { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
353 if (ends.size() == 1) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
354 EndNode end = ends.get(0); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
355 ((FixedWithNextNode) end.predecessor()).setNext(successor); |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
356 oldMerge.removeEnd(end); |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
357 GraphUtil.killCFG(end); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
358 } else { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
359 // Need a new phi in case the frame state is used by more than the merge being |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
360 // removed |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
361 MergeNode newMerge = graph().add(new MergeNode()); |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
362 PhiNode oldPhi = (PhiNode) oldMerge.usages().first(); |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
363 PhiNode newPhi = graph().add(new PhiNode(oldPhi.stamp(), newMerge)); |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
364 |
7316
a64cf8797166
Fix for probabilities of MergeNodes introduced during canonicalization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7257
diff
changeset
|
365 double probability = 0.0; |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
366 for (EndNode end : ends) { |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
367 newPhi.addInput(phiValues.get(end)); |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
368 newMerge.addForwardEnd(end); |
7316
a64cf8797166
Fix for probabilities of MergeNodes introduced during canonicalization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7257
diff
changeset
|
369 probability += end.probability(); |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
370 } |
7316
a64cf8797166
Fix for probabilities of MergeNodes introduced during canonicalization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7257
diff
changeset
|
371 newMerge.setProbability(probability); |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
372 |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
373 FrameState stateAfter = oldMerge.stateAfter(); |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
374 if (stateAfter != null) { |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
375 stateAfter = stateAfter.duplicate(); |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
376 stateAfter.replaceFirstInput(oldPhi, newPhi); |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
377 newMerge.setStateAfter(stateAfter); |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
378 } |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
379 |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6577
diff
changeset
|
380 newMerge.setNext(successor); |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
381 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
382 tool.addToWorkList(successor); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
383 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
384 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
385 |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
386 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
387 * Gets an array of constants derived from a node that is either a {@link ConstantNode} or a |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
388 * {@link PhiNode} whose input values are all constants. The length of the returned array is |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
389 * equal to the number of ends terminating in a given merge node. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
390 * |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
391 * @return null if {@code node} is neither a {@link ConstantNode} nor a {@link PhiNode} whose |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
392 * input values are all constants |
6573
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
393 */ |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
394 private static Constant[] constantValues(ValueNode node, MergeNode merge) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
395 if (node.isConstant()) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
396 Constant[] result = new Constant[merge.forwardEndCount()]; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
397 Arrays.fill(result, node.asConstant()); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
398 return result; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
399 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
400 |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
401 if (node instanceof PhiNode) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
402 PhiNode phi = (PhiNode) node; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
403 if (phi.merge() == merge && phi.type() == PhiType.Value && phi.valueCount() == merge.forwardEndCount()) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
404 Constant[] result = new Constant[merge.forwardEndCount()]; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
405 int i = 0; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
406 for (ValueNode n : phi.values()) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
407 if (!n.isConstant()) { |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
408 return null; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
409 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
410 result[i++] = n.asConstant(); |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
411 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
412 return result; |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
413 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
414 } |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
415 |
4eba1a717254
extended IfNode simplification to try and connect code that initializes a variable directly with the successors of an if construct that switches on the variable
Doug Simon <doug.simon@oracle.com>
parents:
6563
diff
changeset
|
416 return null; |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
417 } |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
418 |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
419 private void removeEmptyIf(SimplifierTool tool) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
420 BeginNode originalTrueSuccessor = trueSuccessor(); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
421 BeginNode originalFalseSuccessor = falseSuccessor(); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
422 assert originalTrueSuccessor.next() instanceof EndNode && originalFalseSuccessor.next() instanceof EndNode; |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
423 |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
424 EndNode trueEnd = (EndNode) originalTrueSuccessor.next(); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
425 EndNode falseEnd = (EndNode) originalFalseSuccessor.next(); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
426 assert trueEnd.merge() == falseEnd.merge(); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
427 |
5206
dfe925845cad
Improve exacuation of anchored values, use it to fix if and merge simplifications
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5083
diff
changeset
|
428 FixedWithNextNode pred = (FixedWithNextNode) predecessor(); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
429 MergeNode merge = trueEnd.merge(); |
5206
dfe925845cad
Improve exacuation of anchored values, use it to fix if and merge simplifications
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5083
diff
changeset
|
430 merge.prepareDelete(pred); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
431 assert merge.usages().isEmpty(); |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
432 originalTrueSuccessor.prepareDelete(); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
433 originalFalseSuccessor.prepareDelete(); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
434 |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
435 FixedNode next = merge.next(); |
7326
6939a5af19d5
Be sure to remove framestate of merge when removing empty diamond shape
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7316
diff
changeset
|
436 FrameState state = merge.stateAfter(); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
437 merge.setNext(null); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
438 setTrueSuccessor(null); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
439 setFalseSuccessor(null); |
5206
dfe925845cad
Improve exacuation of anchored values, use it to fix if and merge simplifications
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5083
diff
changeset
|
440 pred.setNext(next); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
441 safeDelete(); |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
442 originalTrueSuccessor.safeDelete(); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
443 originalFalseSuccessor.safeDelete(); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
444 merge.safeDelete(); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
445 trueEnd.safeDelete(); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
446 falseEnd.safeDelete(); |
7326
6939a5af19d5
Be sure to remove framestate of merge when removing empty diamond shape
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7316
diff
changeset
|
447 if (state != null) { |
6939a5af19d5
Be sure to remove framestate of merge when removing empty diamond shape
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7316
diff
changeset
|
448 tool.removeIfUnused(state); |
6939a5af19d5
Be sure to remove framestate of merge when removing empty diamond shape
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7316
diff
changeset
|
449 } |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
450 tool.addToWorkList(next); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
451 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
452 } |