Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java @ 9467:3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 01 May 2013 16:30:52 +0200 |
parents | ee3279c0f9a0 |
children | 8c37649cbb62 |
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.*; |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
28 import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType; |
9367
1ac1247bb98d
Implemented isnull after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
29 import com.oracle.graal.api.meta.ProfilingInfo.TriState; |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
30 import com.oracle.graal.debug.*; |
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
|
31 import com.oracle.graal.graph.*; |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6590
diff
changeset
|
32 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
|
33 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
|
34 import com.oracle.graal.nodes.calc.*; |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
35 import com.oracle.graal.nodes.java.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
36 import com.oracle.graal.nodes.spi.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
37 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
|
38 import com.oracle.graal.nodes.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
41 * 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
|
42 * of a comparison. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 */ |
5891
fd8832ae511d
removed artifacts of defunct type system
Lukas Stadler <lukas.stadler@jku.at>
parents:
5763
diff
changeset
|
44 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
|
45 |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
46 @Successor private AbstractBeginNode trueSuccessor; |
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
47 @Successor private AbstractBeginNode falseSuccessor; |
7767
4a6646d8eb87
separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7724
diff
changeset
|
48 @Input private LogicNode 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
|
49 private double trueSuccessorProbability; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 |
7767
4a6646d8eb87
separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7724
diff
changeset
|
51 public LogicNode condition() { |
6563
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
52 return condition; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 |
7767
4a6646d8eb87
separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7724
diff
changeset
|
55 public void setCondition(LogicNode x) { |
6563
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
56 updateUsages(condition, x); |
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
57 condition = x; |
5391
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5300
diff
changeset
|
58 } |
5097f21f6c2b
add a new simple CheckCast elimination phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
5300
diff
changeset
|
59 |
7767
4a6646d8eb87
separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7724
diff
changeset
|
60 public IfNode(LogicNode condition, FixedNode trueSuccessor, FixedNode falseSuccessor, double trueSuccessorProbability) { |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
61 this(condition, AbstractBeginNode.begin(trueSuccessor), AbstractBeginNode.begin(falseSuccessor), trueSuccessorProbability); |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
62 } |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
63 |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
64 public IfNode(LogicNode condition, AbstractBeginNode trueSuccessor, AbstractBeginNode falseSuccessor, double trueSuccessorProbability) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
65 super(StampFactory.forVoid()); |
6563
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
66 this.condition = condition; |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
67 this.falseSuccessor = falseSuccessor; |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
68 this.trueSuccessor = trueSuccessor; |
9467
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9441
diff
changeset
|
69 setTrueSuccessorProbability(trueSuccessorProbability); |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
70 |
5695
a63ed5993987
Add leadGraphID to IfNOde so that we can convert them to deopts
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5563
diff
changeset
|
71 } |
a63ed5993987
Add leadGraphID to IfNOde so that we can convert them to deopts
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5563
diff
changeset
|
72 |
3733
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 * Gets the true successor. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
75 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 * @return the true successor |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 */ |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
78 public AbstractBeginNode trueSuccessor() { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
79 return trueSuccessor; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 |
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 * Gets the false successor. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
84 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 * @return the false successor |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 */ |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
87 public AbstractBeginNode falseSuccessor() { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
88 return falseSuccessor; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
91 public void setTrueSuccessor(AbstractBeginNode node) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
92 updatePredecessor(trueSuccessor, node); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
93 trueSuccessor = node; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
96 public void setFalseSuccessor(AbstractBeginNode node) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
97 updatePredecessor(falseSuccessor, node); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
98 falseSuccessor = node; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 * 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
|
103 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 * @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
|
105 * @return the corresponding successor |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 */ |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
107 public AbstractBeginNode successor(boolean istrue) { |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
108 return istrue ? trueSuccessor : falseSuccessor; |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
109 } |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
110 |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
111 @Override |
9440
e35cf6b23b34
Add the condition that was negated in Negatable.negate
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9393
diff
changeset
|
112 public Negatable negate(LogicNode cond) { |
e35cf6b23b34
Add the condition that was negated in Negatable.negate
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9393
diff
changeset
|
113 assert cond == condition(); |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
114 AbstractBeginNode trueSucc = trueSuccessor(); |
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
115 AbstractBeginNode falseSucc = falseSuccessor(); |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
116 setTrueSuccessor(null); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
117 setFalseSuccessor(null); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
118 setTrueSuccessor(falseSucc); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
119 setFalseSuccessor(trueSucc); |
9467
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9441
diff
changeset
|
120 setTrueSuccessorProbability(1 - trueSuccessorProbability); |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
121 return this; |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
122 } |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
123 |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
124 public void setTrueSuccessorProbability(double prob) { |
9467
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9441
diff
changeset
|
125 assert prob >= 0.0 && prob <= 1.0; |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
126 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
|
127 } |
f04a5e46cdd2
new facility to add branch probabilities for snippets, probabilities for frequently-used snippets
Lukas Stadler <lukas.stadler@jku.at>
parents:
7326
diff
changeset
|
128 |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
129 @Override |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
130 public double probability(AbstractBeginNode 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
|
131 return successor == trueSuccessor ? trueSuccessorProbability : 1 - trueSuccessorProbability; |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
134 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
135 public void generate(LIRGeneratorTool gen) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 gen.emitIf(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 public boolean verify() { |
6563
b6eec91d81fb
renamed input for IfNode from 'compare' to 'condition'
Doug Simon <doug.simon@oracle.com>
parents:
5891
diff
changeset
|
141 assertTrue(condition() != null, "missing condition"); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
142 assertTrue(trueSuccessor() != null, "missing trueSuccessor"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 assertTrue(falseSuccessor() != null, "missing falseSuccessor"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
144 return super.verify(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
145 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
146 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 @Override |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
148 public void simplify(SimplifierTool tool) { |
7767
4a6646d8eb87
separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7724
diff
changeset
|
149 if (condition() instanceof LogicConstantNode) { |
4a6646d8eb87
separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7724
diff
changeset
|
150 LogicConstantNode c = (LogicConstantNode) condition(); |
4a6646d8eb87
separate BooleanNode and ConstantNode hierarchy, rename BooleanNode to LogicNode and LogicNode to BitLogicNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7724
diff
changeset
|
151 if (c.getValue()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
152 tool.deleteBranch(falseSuccessor()); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
153 tool.addToWorkList(trueSuccessor()); |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
154 ((StructuredGraph) graph()).removeSplit(this, trueSuccessor()); |
9365
50a81e6eddbc
Improve opportunities for intermediate materialization ifs.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9234
diff
changeset
|
155 return; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
156 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
157 tool.deleteBranch(trueSuccessor()); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
158 tool.addToWorkList(falseSuccessor()); |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
159 ((StructuredGraph) graph()).removeSplit(this, falseSuccessor()); |
9365
50a81e6eddbc
Improve opportunities for intermediate materialization ifs.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9234
diff
changeset
|
160 return; |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
161 } |
9384
86584f07f852
Fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9378
diff
changeset
|
162 } else if (trueSuccessor().usages().isEmpty() && falseSuccessor().usages().isEmpty()) { |
86584f07f852
Fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9378
diff
changeset
|
163 |
9365
50a81e6eddbc
Improve opportunities for intermediate materialization ifs.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9234
diff
changeset
|
164 if (removeOrMaterializeIf(tool)) { |
50a81e6eddbc
Improve opportunities for intermediate materialization ifs.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9234
diff
changeset
|
165 return; |
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 } |
9365
50a81e6eddbc
Improve opportunities for intermediate materialization ifs.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9234
diff
changeset
|
167 } |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
168 |
9386
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
169 if (removeIntermediateMaterialization(tool)) { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
170 return; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
171 } |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
172 |
9373
f11381a65725
Do not swap if nodes when there is a loop exit node between them. Do not swap if one of the compares has unorderedIsTrue set.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9372
diff
changeset
|
173 if (falseSuccessor().usages().isEmpty() && (!(falseSuccessor() instanceof LoopExitNode)) && falseSuccessor().next() instanceof IfNode) { |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
174 AbstractBeginNode intermediateBegin = falseSuccessor(); |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
175 IfNode nextIf = (IfNode) intermediateBegin.next(); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
176 double probabilityB = (1.0 - this.trueSuccessorProbability) * nextIf.trueSuccessorProbability; |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
177 if (this.trueSuccessorProbability < probabilityB) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
178 // Reordering of those two if statements is beneficial from the point of view of |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
179 // their probabilities. |
9369
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
180 if (prepareForSwap(tool.runtime(), condition(), nextIf.condition(), this.trueSuccessorProbability, probabilityB)) { |
9370
3c441e8c9e7f
Added comment.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9369
diff
changeset
|
181 // Reording is allowed from (if1 => begin => if2) to (if2 => begin => if1). |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
182 assert intermediateBegin.next() == nextIf; |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
183 AbstractBeginNode bothFalseBegin = nextIf.falseSuccessor(); |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
184 nextIf.setFalseSuccessor(null); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
185 intermediateBegin.setNext(null); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
186 this.setFalseSuccessor(null); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
187 |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
188 this.replaceAtPredecessor(nextIf); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
189 nextIf.setFalseSuccessor(intermediateBegin); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
190 intermediateBegin.setNext(this); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
191 this.setFalseSuccessor(bothFalseBegin); |
9393
6a2a9eac243a
Correctly adjust probabilities when swapping if nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9390
diff
changeset
|
192 nextIf.setTrueSuccessorProbability(probabilityB); |
9467
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9441
diff
changeset
|
193 if (probabilityB == 1.0) { |
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9441
diff
changeset
|
194 this.setTrueSuccessorProbability(0.0); |
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9441
diff
changeset
|
195 } else { |
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9441
diff
changeset
|
196 double newProbability = this.trueSuccessorProbability / (1.0 - probabilityB); |
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9441
diff
changeset
|
197 this.setTrueSuccessorProbability(Math.min(1.0, newProbability)); |
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9441
diff
changeset
|
198 } |
9369
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
199 return; |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
200 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
201 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
202 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
203 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
204 |
9369
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
205 private static boolean prepareForSwap(MetaAccessProvider runtime, LogicNode a, LogicNode b, double probabilityA, double probabilityB) { |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
206 if (a instanceof InstanceOfNode) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
207 InstanceOfNode instanceOfA = (InstanceOfNode) a; |
9367
1ac1247bb98d
Implemented isnull after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
208 if (b instanceof IsNullNode) { |
1ac1247bb98d
Implemented isnull after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
209 IsNullNode isNullNode = (IsNullNode) b; |
1ac1247bb98d
Implemented isnull after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
210 if (isNullNode.object() == instanceOfA.object()) { |
9378
0e661acc3b4a
Fix null pointer exception in if reordering.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9373
diff
changeset
|
211 if (instanceOfA.profile() != null && instanceOfA.profile().getNullSeen() != TriState.FALSE) { |
9367
1ac1247bb98d
Implemented isnull after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
212 instanceOfA.setProfile(new JavaTypeProfile(TriState.FALSE, instanceOfA.profile().getNotRecordedProbability(), instanceOfA.profile().getTypes())); |
1ac1247bb98d
Implemented isnull after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
213 } |
1ac1247bb98d
Implemented isnull after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
214 Debug.log("Can swap instanceof and isnull if"); |
1ac1247bb98d
Implemented isnull after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
215 return true; |
1ac1247bb98d
Implemented isnull after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
216 } |
1ac1247bb98d
Implemented isnull after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
217 } else if (b instanceof InstanceOfNode) { |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
218 InstanceOfNode instanceOfB = (InstanceOfNode) b; |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
219 if (instanceOfA.object() == instanceOfB.object() && !instanceOfA.type().isAssignableFrom(instanceOfB.type()) && !instanceOfB.type().isAssignableFrom(instanceOfA.type())) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
220 // Two instanceof on the same value with mutually exclusive types. |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
221 JavaTypeProfile profileA = instanceOfA.profile(); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
222 JavaTypeProfile profileB = instanceOfB.profile(); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
223 |
9368
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
224 Debug.log("Can swap instanceof for types %s and %s", instanceOfA.type(), instanceOfB.type()); |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
225 JavaTypeProfile newProfile = null; |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
226 if (profileA != null && profileB != null) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
227 double remainder = 1.0; |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
228 ArrayList<ProfiledType> profiledTypes = new ArrayList<>(); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
229 for (ProfiledType type : profileB.getTypes()) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
230 if (instanceOfB.type().isAssignableFrom(type.getType())) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
231 // Do not add to profile. |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
232 } else { |
9372
98603705e565
Fix capping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9371
diff
changeset
|
233 ProfiledType newType = new ProfiledType(type.getType(), Math.min(1.0, type.getProbability() * (1.0 - probabilityA) / (1.0 - probabilityB))); |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
234 profiledTypes.add(newType); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
235 remainder -= newType.getProbability(); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
236 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
237 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
238 |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
239 for (ProfiledType type : profileA.getTypes()) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
240 if (instanceOfA.type().isAssignableFrom(type.getType())) { |
9372
98603705e565
Fix capping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9371
diff
changeset
|
241 ProfiledType newType = new ProfiledType(type.getType(), Math.min(1.0, type.getProbability() / (1.0 - probabilityB))); |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
242 profiledTypes.add(newType); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
243 remainder -= newType.getProbability(); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
244 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
245 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
246 Collections.sort(profiledTypes); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
247 |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
248 if (remainder < 0.0) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
249 // Can happen due to round-off errors. |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
250 remainder = 0.0; |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
251 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
252 newProfile = new JavaTypeProfile(profileB.getNullSeen(), remainder, profiledTypes.toArray(new ProfiledType[profiledTypes.size()])); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
253 Debug.log("First profile: %s", profileA); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
254 Debug.log("Original second profile: %s", profileB); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
255 Debug.log("New second profile: %s", newProfile); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
256 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
257 instanceOfB.setProfile(profileA); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
258 instanceOfA.setProfile(newProfile); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
259 return true; |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
260 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
261 } |
9368
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
262 } else if (a instanceof CompareNode) { |
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
263 CompareNode compareA = (CompareNode) a; |
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
264 Condition conditionA = compareA.condition(); |
9373
f11381a65725
Do not swap if nodes when there is a loop exit node between them. Do not swap if one of the compares has unorderedIsTrue set.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9372
diff
changeset
|
265 if (compareA.unorderedIsTrue()) { |
f11381a65725
Do not swap if nodes when there is a loop exit node between them. Do not swap if one of the compares has unorderedIsTrue set.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9372
diff
changeset
|
266 return false; |
f11381a65725
Do not swap if nodes when there is a loop exit node between them. Do not swap if one of the compares has unorderedIsTrue set.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9372
diff
changeset
|
267 } |
9368
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
268 if (b instanceof CompareNode) { |
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
269 CompareNode compareB = (CompareNode) b; |
9369
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
270 if (compareA == compareB) { |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
271 Debug.log("Same conditions => do not swap and leave the work for global value numbering."); |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
272 return false; |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
273 } |
9373
f11381a65725
Do not swap if nodes when there is a loop exit node between them. Do not swap if one of the compares has unorderedIsTrue set.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9372
diff
changeset
|
274 if (compareB.unorderedIsTrue()) { |
f11381a65725
Do not swap if nodes when there is a loop exit node between them. Do not swap if one of the compares has unorderedIsTrue set.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9372
diff
changeset
|
275 return false; |
f11381a65725
Do not swap if nodes when there is a loop exit node between them. Do not swap if one of the compares has unorderedIsTrue set.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9372
diff
changeset
|
276 } |
9369
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
277 Condition comparableCondition = null; |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
278 Condition conditionB = compareB.condition(); |
9368
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
279 if (compareB.x() == compareA.x() && compareB.y() == compareA.y()) { |
9369
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
280 comparableCondition = conditionB; |
9368
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
281 } else if (compareB.x() == compareA.y() && compareB.y() == compareA.x()) { |
9369
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
282 comparableCondition = conditionB.mirror(); |
9368
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
283 } |
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
284 |
9369
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
285 if (comparableCondition != null) { |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
286 Condition combined = conditionA.join(comparableCondition); |
9368
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
287 if (combined == null) { |
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
288 // The two conditions are disjoint => can reorder. |
9369
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
289 Debug.log("Can swap disjoint coditions on same values: %s and %s", conditionA, comparableCondition); |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
290 return true; |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
291 } |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
292 } else if (conditionA == Condition.EQ && conditionB == Condition.EQ) { |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
293 boolean canSwap = false; |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
294 if ((compareA.x() == compareB.x() && valuesDistinct(runtime, compareA.y(), compareB.y()))) { |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
295 canSwap = true; |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
296 } else if ((compareA.x() == compareB.y() && valuesDistinct(runtime, compareA.y(), compareB.x()))) { |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
297 canSwap = true; |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
298 } else if ((compareA.y() == compareB.x() && valuesDistinct(runtime, compareA.x(), compareB.y()))) { |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
299 canSwap = true; |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
300 } else if ((compareA.y() == compareB.y() && valuesDistinct(runtime, compareA.x(), compareB.x()))) { |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
301 canSwap = true; |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
302 } |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
303 |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
304 if (canSwap) { |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
305 Debug.log("Can swap equality condition with one shared and one disjoint value."); |
9368
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
306 return true; |
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
307 } |
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
308 } |
3b4f3f92879e
Implement swapping for distinct conditions on same values.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9367
diff
changeset
|
309 } |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
310 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
311 |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9365
diff
changeset
|
312 return false; |
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
|
313 } |
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 |
9369
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
315 private static boolean valuesDistinct(MetaAccessProvider runtime, ValueNode a, ValueNode b) { |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
316 if (a.isConstant() && b.isConstant()) { |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
317 return !runtime.constantEquals(a.asConstant(), b.asConstant()); |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
318 } |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
319 |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
320 Stamp stampA = a.stamp(); |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
321 Stamp stampB = b.stamp(); |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
322 return stampA.alwaysDistinct(stampB); |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
323 } |
442643db2a52
Implement swapping of == if one value is proven equal and the other is proven distinct.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9368
diff
changeset
|
324 |
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
|
325 /** |
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 * 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
|
327 * |
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
|
328 * @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
|
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 private boolean removeOrMaterializeIf(SimplifierTool tool) { |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
331 if (trueSuccessor().next() instanceof AbstractEndNode && falseSuccessor().next() instanceof AbstractEndNode) { |
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
332 AbstractEndNode trueEnd = (AbstractEndNode) trueSuccessor().next(); |
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
333 AbstractEndNode falseEnd = (AbstractEndNode) falseSuccessor().next(); |
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
|
334 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
|
335 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
|
336 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
|
337 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
|
338 // 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
|
339 removeEmptyIf(tool); |
9365
50a81e6eddbc
Improve opportunities for intermediate materialization ifs.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9234
diff
changeset
|
340 return true; |
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
|
341 } 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
|
342 PhiNode singlePhi = phis.next(); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
343 if (!phis.hasNext()) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
344 // 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
|
345 // into a MaterializeNode |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
346 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
|
347 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
|
348 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
|
349 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
|
350 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
|
351 } |
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 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
|
353 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
|
354 } |
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 if (trueValue.isConstant() && falseValue.isConstant()) { |
7724
ac3579b4adc9
remove MaterializeNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7694
diff
changeset
|
356 ConditionalNode materialize = graph().unique(new ConditionalNode(condition(), trueValue, falseValue)); |
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 ((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
|
358 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
|
359 return true; |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
360 } |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
361 } |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
362 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
363 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
364 } |
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
|
365 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
|
366 } |
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
|
367 |
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
|
368 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
369 * 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
|
370 * 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
|
371 * |
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
|
372 * <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
|
373 * 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
|
374 * 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
|
375 * 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
|
376 * } 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
|
377 * 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
|
378 * 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
|
379 * 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
|
380 * 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
|
381 * 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
|
382 * } |
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 * 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
|
386 * 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
|
387 * } 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
|
388 * 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
|
389 * } |
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
|
390 * } |
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
|
391 * </pre> |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
392 * |
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 * will be transformed into: |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
394 * |
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
|
395 * <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
|
396 * 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
|
397 * 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
|
398 * 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
|
399 * } 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
|
400 * 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
|
401 * 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
|
402 * 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
|
403 * 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
|
404 * } |
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 * } |
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 * 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
|
407 * } |
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 * } |
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 * </pre> |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
410 * |
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
|
411 * @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
|
412 */ |
9386
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
413 private boolean removeIntermediateMaterialization(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
|
414 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
|
415 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
|
416 } |
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
|
417 |
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
|
418 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
|
419 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
|
420 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
|
421 } |
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
|
422 |
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
|
423 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
|
424 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
|
425 } |
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
|
426 |
9384
86584f07f852
Fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9378
diff
changeset
|
427 if (predecessor() instanceof LoopBeginNode) { |
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
|
428 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
|
429 } |
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
|
430 |
9384
86584f07f852
Fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9378
diff
changeset
|
431 MergeNode merge = (MergeNode) predecessor(); |
86584f07f852
Fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9378
diff
changeset
|
432 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
433 // 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
|
434 // comparison |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6590
diff
changeset
|
435 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
|
436 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
|
437 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
|
438 } |
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
|
439 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
|
440 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
|
441 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
|
442 } |
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
|
443 |
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
|
444 // 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
|
445 PhiNode phi = (PhiNode) singleUsage; |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6590
diff
changeset
|
446 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
|
447 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
|
448 return false; |
dc5eec61daba
removing intermediate materialization with frame-state-full merges now works
Doug Simon <doug.simon@oracle.com>
parents:
6586
diff
changeset
|
449 } |
dc5eec61daba
removing intermediate materialization with frame-state-full merges now works
Doug Simon <doug.simon@oracle.com>
parents:
6586
diff
changeset
|
450 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
|
451 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
|
452 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
|
453 } |
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
|
454 } |
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
|
455 |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
456 List<AbstractEndNode> mergePredecessors = merge.cfgPredecessors().snapshot(); |
9384
86584f07f852
Fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9378
diff
changeset
|
457 assert phi.valueCount() == merge.forwardEndCount(); |
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
|
458 |
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
|
459 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
|
460 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
|
461 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
|
462 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
|
463 } |
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
|
464 |
9386
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
465 // Sanity check that both ends are not followed by a merge without frame state. |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
466 if (!checkFrameState(trueSuccessor()) && !checkFrameState(falseSuccessor())) { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
467 return false; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
468 } |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
469 |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
470 List<AbstractEndNode> falseEnds = new ArrayList<>(mergePredecessors.size()); |
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
471 List<AbstractEndNode> trueEnds = new ArrayList<>(mergePredecessors.size()); |
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
472 Map<AbstractEndNode, 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
|
473 |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
474 AbstractBeginNode oldFalseSuccessor = falseSuccessor(); |
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
475 AbstractBeginNode 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
|
476 |
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
|
477 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
|
478 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
|
479 |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
480 Iterator<AbstractEndNode> ends = mergePredecessors.iterator(); |
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
|
481 for (int i = 0; i < xs.length; i++) { |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
482 AbstractEndNode 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
|
483 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
|
484 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
|
485 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
|
486 } 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
|
487 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
|
488 } |
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
|
489 } |
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
|
490 assert !ends.hasNext(); |
7684
bbf97d6688d3
cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7368
diff
changeset
|
491 assert falseEnds.size() + trueEnds.size() == xs.length; |
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
|
492 |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
493 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
|
494 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
|
495 |
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
|
496 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
|
497 |
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
|
498 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
|
499 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
|
500 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
|
501 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
|
502 |
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
|
503 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
|
504 } |
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
|
505 |
9386
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
506 private static boolean checkFrameState(FixedNode start) { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
507 FixedNode node = start; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
508 while (true) { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
509 if (node instanceof MergeNode) { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
510 MergeNode mergeNode = (MergeNode) node; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
511 if (mergeNode.stateAfter() == null) { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
512 return false; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
513 } else { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
514 return true; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
515 } |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
516 } else if (node instanceof StateSplit) { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
517 StateSplit stateSplitNode = (StateSplit) node; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
518 if (stateSplitNode.stateAfter() != null) { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
519 return true; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
520 } |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
521 } |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
522 |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
523 if (node instanceof ControlSplitNode) { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
524 ControlSplitNode controlSplitNode = (ControlSplitNode) node; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
525 for (Node succ : controlSplitNode.cfgSuccessors()) { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
526 if (checkFrameState((FixedNode) succ)) { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
527 return true; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
528 } |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
529 } |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
530 return false; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
531 } else if (node instanceof FixedWithNextNode) { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
532 FixedWithNextNode fixedWithNextNode = (FixedWithNextNode) node; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
533 node = fixedWithNextNode.next(); |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
534 } else if (node instanceof AbstractEndNode) { |
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
535 AbstractEndNode endNode = (AbstractEndNode) node; |
9386
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
536 node = endNode.merge(); |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
537 } else if (node instanceof ControlSinkNode) { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
538 return true; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
539 } else { |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
540 return false; |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
541 } |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
542 } |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
543 } |
4a9fd6d90284
Implement alternative fix for removeIntermediateMaterialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9385
diff
changeset
|
544 |
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
|
545 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
546 * 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
|
547 * 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
|
548 * {@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
|
549 * {@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
|
550 * |
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
|
551 * @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
|
552 * @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
|
553 */ |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
554 private void connectEnds(List<AbstractEndNode> ends, Map<AbstractEndNode, ValueNode> phiValues, AbstractBeginNode 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
|
555 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
|
556 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
|
557 } 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
|
558 if (ends.size() == 1) { |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
559 AbstractEndNode end = ends.get(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
|
560 ((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
|
561 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
|
562 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
|
563 } else { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
564 // 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
|
565 // 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
|
566 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
|
567 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
|
568 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
|
569 |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
570 for (AbstractEndNode 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
|
571 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
|
572 newMerge.addForwardEnd(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
|
573 } |
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
|
574 |
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
|
575 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
|
576 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
|
577 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
|
578 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
|
579 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
|
580 } |
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
|
581 |
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
|
582 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
|
583 } |
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
|
584 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
|
585 } |
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
|
586 } |
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
|
587 |
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
|
588 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
589 * 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
|
590 * {@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
|
591 * 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
|
592 * |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7368
diff
changeset
|
593 * @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
|
594 * 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
|
595 */ |
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
|
596 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
|
597 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
|
598 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
|
599 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
|
600 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
|
601 } |
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
|
602 |
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
|
603 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
|
604 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
|
605 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
|
606 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
|
607 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
|
608 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
|
609 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
|
610 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
|
611 } |
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
|
612 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
|
613 } |
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
|
614 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
|
615 } |
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
|
616 } |
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
|
617 |
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
|
618 return null; |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
619 } |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
620 |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
621 private void removeEmptyIf(SimplifierTool tool) { |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
622 AbstractBeginNode originalTrueSuccessor = trueSuccessor(); |
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
623 AbstractBeginNode originalFalseSuccessor = falseSuccessor(); |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
624 assert originalTrueSuccessor.next() instanceof AbstractEndNode && originalFalseSuccessor.next() instanceof AbstractEndNode; |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
625 |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
626 AbstractEndNode trueEnd = (AbstractEndNode) originalTrueSuccessor.next(); |
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9393
diff
changeset
|
627 AbstractEndNode falseEnd = (AbstractEndNode) originalFalseSuccessor.next(); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
628 assert trueEnd.merge() == falseEnd.merge(); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
629 |
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
|
630 FixedWithNextNode pred = (FixedWithNextNode) predecessor(); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
631 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
|
632 merge.prepareDelete(pred); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
633 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
|
634 originalTrueSuccessor.prepareDelete(); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
635 originalFalseSuccessor.prepareDelete(); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
636 |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
637 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
|
638 FrameState state = merge.stateAfter(); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
639 merge.setNext(null); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
640 setTrueSuccessor(null); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
641 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
|
642 pred.setNext(next); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
643 safeDelete(); |
7257
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
644 originalTrueSuccessor.safeDelete(); |
b1ebd583be14
Remove @Successor private final NodeSuccessorList<BeginNode> blockSuccessors from ControlSplitNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7123
diff
changeset
|
645 originalFalseSuccessor.safeDelete(); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
646 merge.safeDelete(); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
647 trueEnd.safeDelete(); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
648 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
|
649 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
|
650 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
|
651 } |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
652 tool.addToWorkList(next); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
653 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
654 } |