Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java @ 22872:ad106dd2000c
Fix missing transfer of speculation when recreating guards/deops
All fields need to be transfered (reason, action and speculation).
When we drop the speculation object we risk infinite deopts.
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Tue, 20 Oct 2015 15:55:40 +0200 |
parents | 615f3bbbb174 |
children | 2fe4e3511d97 |
rev | line source |
---|---|
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.phases.common; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
22790
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22646
diff
changeset
|
25 import static jdk.vm.ci.meta.DeoptimizationAction.InvalidateReprofile; |
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22646
diff
changeset
|
26 import static jdk.vm.ci.meta.DeoptimizationReason.UnreachedCode; |
19719
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
27 |
22646
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
28 import java.util.ArrayDeque; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
29 import java.util.ArrayList; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
30 import java.util.Collections; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
31 import java.util.Deque; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
32 import java.util.Iterator; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
33 import java.util.List; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
34 import java.util.function.Function; |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 |
22790
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22646
diff
changeset
|
36 import jdk.vm.ci.meta.JavaConstant; |
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22646
diff
changeset
|
37 import jdk.vm.ci.meta.TriState; |
22054 | 38 |
22646
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
39 import com.oracle.graal.compiler.common.cfg.AbstractControlFlowGraph; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
40 import com.oracle.graal.compiler.common.cfg.BlockMap; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
41 import com.oracle.graal.compiler.common.type.Stamp; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
42 import com.oracle.graal.compiler.common.type.StampFactory; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
43 import com.oracle.graal.debug.Debug; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
44 import com.oracle.graal.debug.DebugMetric; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
45 import com.oracle.graal.graph.Node; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
46 import com.oracle.graal.graph.NodeMap; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
47 import com.oracle.graal.nodeinfo.InputType; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
48 import com.oracle.graal.nodes.AbstractBeginNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
49 import com.oracle.graal.nodes.BeginNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
50 import com.oracle.graal.nodes.BinaryOpLogicNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
51 import com.oracle.graal.nodes.ConditionAnchorNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
52 import com.oracle.graal.nodes.DeoptimizeNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
53 import com.oracle.graal.nodes.FixedGuardNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
54 import com.oracle.graal.nodes.FixedNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
55 import com.oracle.graal.nodes.GuardNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
56 import com.oracle.graal.nodes.GuardProxyNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
57 import com.oracle.graal.nodes.IfNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
58 import com.oracle.graal.nodes.LogicNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
59 import com.oracle.graal.nodes.LoopExitNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
60 import com.oracle.graal.nodes.PiNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
61 import com.oracle.graal.nodes.ShortCircuitOrNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
62 import com.oracle.graal.nodes.StructuredGraph; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
63 import com.oracle.graal.nodes.UnaryOpLogicNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
64 import com.oracle.graal.nodes.ValueNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
65 import com.oracle.graal.nodes.cfg.Block; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
66 import com.oracle.graal.nodes.cfg.ControlFlowGraph; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
67 import com.oracle.graal.nodes.extended.GuardingNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
68 import com.oracle.graal.nodes.extended.IntegerSwitchNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
69 import com.oracle.graal.nodes.extended.LoadHubNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
70 import com.oracle.graal.nodes.extended.ValueAnchorNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
71 import com.oracle.graal.nodes.java.CheckCastNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
72 import com.oracle.graal.nodes.java.TypeSwitchNode; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
73 import com.oracle.graal.nodes.util.GraphUtil; |
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
74 import com.oracle.graal.phases.Phase; |
21160
0c03a7b7081f
fix in DominatorConditionalEliminationPhase for If/ShortCircuitOr with xNegated=true
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21150
diff
changeset
|
75 import com.oracle.graal.phases.common.LoweringPhase.Frame; |
22646
05183a084a08
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22300
diff
changeset
|
76 import com.oracle.graal.phases.schedule.SchedulePhase; |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 public class DominatorConditionalEliminationPhase extends Phase { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 private static final DebugMetric metricStampsRegistered = Debug.metric("StampsRegistered"); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 private static final DebugMetric metricStampsFound = Debug.metric("StampsFound"); |
19721
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
82 private final boolean fullSchedule; |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 |
19721
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
84 public DominatorConditionalEliminationPhase(boolean fullSchedule) { |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
85 this.fullSchedule = fullSchedule; |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 private static final class InfoElement { |
21160
0c03a7b7081f
fix in DominatorConditionalEliminationPhase for If/ShortCircuitOr with xNegated=true
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21150
diff
changeset
|
89 private final Stamp stamp; |
0c03a7b7081f
fix in DominatorConditionalEliminationPhase for If/ShortCircuitOr with xNegated=true
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21150
diff
changeset
|
90 private final ValueNode guard; |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 public InfoElement(Stamp stamp, ValueNode guard) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 this.stamp = stamp; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 this.guard = guard; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 public Stamp getStamp() { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 return stamp; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 public ValueNode getGuard() { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 return guard; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 } |
21160
0c03a7b7081f
fix in DominatorConditionalEliminationPhase for If/ShortCircuitOr with xNegated=true
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21150
diff
changeset
|
104 |
0c03a7b7081f
fix in DominatorConditionalEliminationPhase for If/ShortCircuitOr with xNegated=true
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21150
diff
changeset
|
105 @Override |
0c03a7b7081f
fix in DominatorConditionalEliminationPhase for If/ShortCircuitOr with xNegated=true
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21150
diff
changeset
|
106 public String toString() { |
0c03a7b7081f
fix in DominatorConditionalEliminationPhase for If/ShortCircuitOr with xNegated=true
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21150
diff
changeset
|
107 return stamp + " -> " + guard; |
0c03a7b7081f
fix in DominatorConditionalEliminationPhase for If/ShortCircuitOr with xNegated=true
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21150
diff
changeset
|
108 } |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
111 private static final class Info { |
21160
0c03a7b7081f
fix in DominatorConditionalEliminationPhase for If/ShortCircuitOr with xNegated=true
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21150
diff
changeset
|
112 private final ArrayList<InfoElement> infos; |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 public Info() { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 infos = new ArrayList<>(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 public Iterable<InfoElement> getElements() { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 return infos; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 public void pushElement(InfoElement element) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 infos.add(element); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 public void popElement() { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 infos.remove(infos.size() - 1); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 @Override |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
132 protected void run(StructuredGraph graph) { |
19721
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
133 |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
134 Function<Block, Iterable<? extends Node>> blockToNodes; |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
135 Function<Node, Block> nodeToBlock; |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
136 Block startBlock; |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
137 |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
138 if (fullSchedule) { |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
139 SchedulePhase schedule = new SchedulePhase(SchedulePhase.SchedulingStrategy.EARLIEST); |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
140 schedule.apply(graph); |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
141 ControlFlowGraph cfg = schedule.getCFG(); |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
142 cfg.computePostdominators(); |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
143 blockToNodes = b -> schedule.getBlockToNodesMap().get(b); |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
144 nodeToBlock = n -> schedule.getNodeToBlockMap().get(n); |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
145 startBlock = cfg.getStartBlock(); |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
146 } else { |
21619
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
147 ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true); |
19721
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
148 cfg.computePostdominators(); |
19762
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
149 BlockMap<List<FixedNode>> nodes = new BlockMap<>(cfg); |
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
150 for (Block b : cfg.getBlocks()) { |
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
151 ArrayList<FixedNode> curNodes = new ArrayList<>(); |
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
152 for (FixedNode node : b.getNodes()) { |
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
153 if (node instanceof AbstractBeginNode || node instanceof FixedGuardNode || node instanceof CheckCastNode || node instanceof ConditionAnchorNode || node instanceof IfNode) { |
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
154 curNodes.add(node); |
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
155 } |
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
156 } |
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
157 nodes.put(b, curNodes); |
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
158 } |
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
159 blockToNodes = b -> nodes.get(b); |
19721
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
160 nodeToBlock = n -> cfg.blockFor(n); |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
161 startBlock = cfg.getStartBlock(); |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
162 } |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
163 |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
164 Instance instance = new Instance(graph, blockToNodes, nodeToBlock); |
b503dd4e723c
Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19719
diff
changeset
|
165 instance.processBlock(startBlock); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
167 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
168 private static class Instance { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
169 |
21619
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
170 private NodeMap<Info> map; |
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
171 private Deque<LoopExitNode> loopExits; |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 private final Function<Block, Iterable<? extends Node>> blockToNodes; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 private final Function<Node, Block> nodeToBlock; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
174 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
175 public Instance(StructuredGraph graph, Function<Block, Iterable<? extends Node>> blockToNodes, Function<Node, Block> nodeToBlock) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
176 map = graph.createNodeMap(); |
20040
f137f1974f60
removed uses of StringBuffer, Hashtable and Stack
Doug Simon <doug.simon@oracle.com>
parents:
19950
diff
changeset
|
177 loopExits = new ArrayDeque<>(); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
178 this.blockToNodes = blockToNodes; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 this.nodeToBlock = nodeToBlock; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 |
20931
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
182 public void processBlock(Block startBlock) { |
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
183 LoweringPhase.processBlock(new InstanceFrame(startBlock, null)); |
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
184 } |
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
185 |
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
186 public class InstanceFrame extends LoweringPhase.Frame<InstanceFrame> { |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 List<Runnable> undoOperations = new ArrayList<>(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
188 |
20931
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
189 public InstanceFrame(Block block, InstanceFrame parent) { |
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
190 super(block, parent); |
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
191 } |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 |
20931
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
193 @Override |
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
194 public Frame<?> enter(Block b) { |
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
195 return new InstanceFrame(b, this); |
19731
19a4fbe393d0
Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19728
diff
changeset
|
196 } |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
197 |
20931
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
198 @Override |
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
199 public void preprocess() { |
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
200 Instance.this.preprocess(block, undoOperations); |
19731
19a4fbe393d0
Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19728
diff
changeset
|
201 } |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
202 |
20931
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
203 @Override |
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
204 public void postprocess() { |
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
205 Instance.postprocess(undoOperations); |
d9713313e88c
Change recursive LoweringPhase.Round.processBlock to state machine with emulated stack. Also use the same traversal in DominatorConditionalEliminationPhase.Instance.processBlock. Required, as the recursive implementation exceeds the stack on SPARC.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
20174
diff
changeset
|
206 } |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 private static void postprocess(List<Runnable> undoOperations) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
210 for (Runnable r : undoOperations) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
211 r.run(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
214 |
19731
19a4fbe393d0
Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19728
diff
changeset
|
215 private void preprocess(Block block, List<Runnable> undoOperations) { |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
216 AbstractBeginNode beginNode = block.getBeginNode(); |
19731
19a4fbe393d0
Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19728
diff
changeset
|
217 if (beginNode instanceof LoopExitNode && beginNode.isAlive()) { |
19a4fbe393d0
Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19728
diff
changeset
|
218 LoopExitNode loopExitNode = (LoopExitNode) beginNode; |
19a4fbe393d0
Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19728
diff
changeset
|
219 this.loopExits.push(loopExitNode); |
19a4fbe393d0
Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19728
diff
changeset
|
220 undoOperations.add(() -> loopExits.pop()); |
21619
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
221 } else if (block.getDominator() != null && |
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
222 (block.getDominator().getLoopDepth() > block.getLoopDepth() || (block.getDominator().getLoopDepth() == block.getLoopDepth() && block.getDominator().getLoop() != block.getLoop()))) { |
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
223 // We are exiting the loop, but there is not a single loop exit block along our |
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
224 // dominator tree (e.g., we are a merge of two loop exits). |
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
225 final NodeMap<Info> oldMap = map; |
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
226 final Deque<LoopExitNode> oldLoopExits = loopExits; |
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
227 map = map.graph().createNodeMap(); |
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
228 loopExits = new ArrayDeque<>(); |
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
229 undoOperations.add(() -> { |
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
230 map = oldMap; |
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
231 loopExits = oldLoopExits; |
b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21585
diff
changeset
|
232 }); |
19731
19a4fbe393d0
Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19728
diff
changeset
|
233 } |
19a4fbe393d0
Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19728
diff
changeset
|
234 for (Node n : blockToNodes.apply(block)) { |
19a4fbe393d0
Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19728
diff
changeset
|
235 if (n.isAlive()) { |
19a4fbe393d0
Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19728
diff
changeset
|
236 processNode(n, undoOperations); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
237 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
238 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
239 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
240 |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
241 private void processNode(Node node, List<Runnable> undoOperations) { |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
242 if (node instanceof AbstractBeginNode) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
243 processAbstractBegin((AbstractBeginNode) node, undoOperations); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
244 } else if (node instanceof FixedGuardNode) { |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
245 processFixedGuard((FixedGuardNode) node, undoOperations); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
246 } else if (node instanceof GuardNode) { |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
247 processGuard((GuardNode) node, undoOperations); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
248 } else if (node instanceof CheckCastNode) { |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
249 processCheckCast((CheckCastNode) node); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
250 } else if (node instanceof ConditionAnchorNode) { |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
251 processConditionAnchor((ConditionAnchorNode) node); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
252 } else if (node instanceof IfNode) { |
19762
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
253 processIf((IfNode) node, undoOperations); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
254 } else { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
255 return; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
256 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
257 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
258 |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
259 private void processCheckCast(CheckCastNode node) { |
21037
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
260 for (InfoElement infoElement : getInfoElements(node.object())) { |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
261 TriState result = node.tryFold(infoElement.getStamp()); |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
262 if (result.isKnown()) { |
21039
13a255e29236
Conditional Elimination: processCheckCast should return as soon as the checkcast has been transformed
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21038
diff
changeset
|
263 if (rewireGuards(infoElement.getGuard(), result.toBoolean(), (guard, checkCastResult) -> { |
21037
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
264 if (checkCastResult) { |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
265 PiNode piNode = node.graph().unique(new PiNode(node.object(), node.stamp(), guard)); |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
266 node.replaceAtUsages(piNode); |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
267 GraphUtil.unlinkFixedNode(node); |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
268 node.safeDelete(); |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
269 } else { |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
270 DeoptimizeNode deopt = node.graph().add(new DeoptimizeNode(InvalidateReprofile, UnreachedCode)); |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
271 node.replaceAtPredecessor(deopt); |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
272 GraphUtil.killCFG(node); |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
273 } |
21038
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
274 return true; |
21039
13a255e29236
Conditional Elimination: processCheckCast should return as soon as the checkcast has been transformed
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21038
diff
changeset
|
275 })) { |
13a255e29236
Conditional Elimination: processCheckCast should return as soon as the checkcast has been transformed
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21038
diff
changeset
|
276 return; |
13a255e29236
Conditional Elimination: processCheckCast should return as soon as the checkcast has been transformed
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21038
diff
changeset
|
277 } |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
278 } |
21037
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
279 } |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
280 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
281 |
19762
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
282 private void processIf(IfNode node, List<Runnable> undoOperations) { |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
283 tryProofCondition(node.condition(), (guard, result) -> { |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
284 AbstractBeginNode survivingSuccessor = node.getSuccessor(result); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
285 survivingSuccessor.replaceAtUsages(InputType.Guard, guard); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
286 survivingSuccessor.replaceAtPredecessor(null); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
287 node.replaceAtPredecessor(survivingSuccessor); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
288 GraphUtil.killCFG(node); |
21585
453284d62d64
Fix a bug in the dominator based conditional elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21556
diff
changeset
|
289 if (survivingSuccessor instanceof BeginNode) { |
453284d62d64
Fix a bug in the dominator based conditional elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21556
diff
changeset
|
290 undoOperations.add(() -> { |
453284d62d64
Fix a bug in the dominator based conditional elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21556
diff
changeset
|
291 if (survivingSuccessor.isAlive()) { |
453284d62d64
Fix a bug in the dominator based conditional elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21556
diff
changeset
|
292 ((BeginNode) survivingSuccessor).trySimplify(); |
453284d62d64
Fix a bug in the dominator based conditional elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21556
diff
changeset
|
293 } |
453284d62d64
Fix a bug in the dominator based conditional elimination.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
21556
diff
changeset
|
294 }); |
19728
4df907480030
Simplify begin node immediately after removing if node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19724
diff
changeset
|
295 } |
21038
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
296 return true; |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
297 }); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
298 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
299 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
300 private void registerNewCondition(LogicNode condition, boolean negated, ValueNode guard, List<Runnable> undoOperations) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
301 if (condition instanceof UnaryOpLogicNode) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
302 UnaryOpLogicNode unaryLogicNode = (UnaryOpLogicNode) condition; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
303 Stamp newStamp = unaryLogicNode.getSucceedingStampForValue(negated); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
304 registerNewStamp(unaryLogicNode.getValue(), newStamp, guard, undoOperations); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
305 } else if (condition instanceof BinaryOpLogicNode) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
306 BinaryOpLogicNode binaryOpLogicNode = (BinaryOpLogicNode) condition; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
307 ValueNode x = binaryOpLogicNode.getX(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
308 if (!x.isConstant()) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
309 Stamp newStampX = binaryOpLogicNode.getSucceedingStampForX(negated); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
310 registerNewStamp(x, newStampX, guard, undoOperations); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
311 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
312 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
313 ValueNode y = binaryOpLogicNode.getY(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
314 if (!y.isConstant()) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
315 Stamp newStampY = binaryOpLogicNode.getSucceedingStampForY(negated); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
316 registerNewStamp(y, newStampY, guard, undoOperations); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
317 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
318 } |
21036
953666b61a23
Always register stamps for the condition itself
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
20934
diff
changeset
|
319 registerCondition(condition, negated, guard, undoOperations); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
320 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
321 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
322 private void registerCondition(LogicNode condition, boolean negated, ValueNode guard, List<Runnable> undoOperations) { |
21160
0c03a7b7081f
fix in DominatorConditionalEliminationPhase for If/ShortCircuitOr with xNegated=true
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21150
diff
changeset
|
323 registerNewStamp(condition, negated ? StampFactory.contradiction() : StampFactory.tautology(), guard, undoOperations); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
324 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
325 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
326 private Iterable<InfoElement> getInfoElements(ValueNode proxiedValue) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
327 ValueNode value = GraphUtil.unproxify(proxiedValue); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
328 Info info = map.get(value); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
329 if (info == null) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
330 return Collections.emptyList(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
331 } else { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
332 return info.getElements(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
333 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
334 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
335 |
21038
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
336 private boolean rewireGuards(ValueNode guard, boolean result, GuardRewirer rewireGuardFunction) { |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
337 assert guard instanceof GuardingNode; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
338 metricStampsFound.increment(); |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
339 ValueNode proxiedGuard = proxyGuard(guard); |
21038
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
340 return rewireGuardFunction.rewire(proxiedGuard, result); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
341 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
342 |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
343 private ValueNode proxyGuard(ValueNode guard) { |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
344 ValueNode proxiedGuard = guard; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
345 if (!this.loopExits.isEmpty()) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
346 while (proxiedGuard instanceof GuardProxyNode) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
347 proxiedGuard = ((GuardProxyNode) proxiedGuard).value(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
348 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
349 Block guardBlock = nodeToBlock.apply(proxiedGuard); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
350 assert guardBlock != null; |
20040
f137f1974f60
removed uses of StringBuffer, Hashtable and Stack
Doug Simon <doug.simon@oracle.com>
parents:
19950
diff
changeset
|
351 for (Iterator<LoopExitNode> iter = loopExits.descendingIterator(); iter.hasNext();) { |
f137f1974f60
removed uses of StringBuffer, Hashtable and Stack
Doug Simon <doug.simon@oracle.com>
parents:
19950
diff
changeset
|
352 LoopExitNode loopExitNode = iter.next(); |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
353 Block loopExitBlock = nodeToBlock.apply(loopExitNode); |
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
354 if (guardBlock != loopExitBlock && AbstractControlFlowGraph.dominates(guardBlock, loopExitBlock)) { |
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
355 Block loopBeginBlock = nodeToBlock.apply(loopExitNode.loopBegin()); |
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
356 if (!AbstractControlFlowGraph.dominates(guardBlock, loopBeginBlock) || guardBlock == loopBeginBlock) { |
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
357 proxiedGuard = proxiedGuard.graph().unique(new GuardProxyNode((GuardingNode) proxiedGuard, loopExitNode)); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
358 } |
19719
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
359 } |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
360 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
361 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
362 return proxiedGuard; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
363 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
364 |
21038
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
365 @FunctionalInterface |
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
366 private interface GuardRewirer { |
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
367 /** |
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
368 * Called if the condition could be proven to have a constant value ({@code result}) |
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
369 * under {@code guard}. |
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
370 * |
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
371 * Return whether a transformation could be applied. |
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
372 */ |
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
373 boolean rewire(ValueNode guard, boolean result); |
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
374 } |
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
375 |
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
376 private boolean tryProofCondition(LogicNode node, GuardRewirer rewireGuardFunction) { |
21037
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
377 for (InfoElement infoElement : getInfoElements(node)) { |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
378 Stamp stamp = infoElement.getStamp(); |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
379 JavaConstant constant = (JavaConstant) stamp.asConstant(); |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
380 if (constant != null) { |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
381 return rewireGuards(infoElement.getGuard(), constant.asBoolean(), rewireGuardFunction); |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
382 } |
3fc34aafea30
Conditional elimination: check if conditional has known value already
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21036
diff
changeset
|
383 } |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
384 if (node instanceof UnaryOpLogicNode) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
385 UnaryOpLogicNode unaryLogicNode = (UnaryOpLogicNode) node; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
386 ValueNode value = unaryLogicNode.getValue(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
387 for (InfoElement infoElement : getInfoElements(value)) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
388 Stamp stamp = infoElement.getStamp(); |
19724
70d565f6e127
Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19723
diff
changeset
|
389 TriState result = unaryLogicNode.tryFold(stamp); |
70d565f6e127
Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19723
diff
changeset
|
390 if (result.isKnown()) { |
70d565f6e127
Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19723
diff
changeset
|
391 return rewireGuards(infoElement.getGuard(), result.toBoolean(), rewireGuardFunction); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
392 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
393 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
394 } else if (node instanceof BinaryOpLogicNode) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
395 BinaryOpLogicNode binaryOpLogicNode = (BinaryOpLogicNode) node; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
396 for (InfoElement infoElement : getInfoElements(binaryOpLogicNode)) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
397 if (infoElement.getStamp().equals(StampFactory.contradiction())) { |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
398 return rewireGuards(infoElement.getGuard(), false, rewireGuardFunction); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
399 } else if (infoElement.getStamp().equals(StampFactory.tautology())) { |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
400 return rewireGuards(infoElement.getGuard(), true, rewireGuardFunction); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
401 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
402 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
403 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
404 ValueNode x = binaryOpLogicNode.getX(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
405 ValueNode y = binaryOpLogicNode.getY(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
406 for (InfoElement infoElement : getInfoElements(x)) { |
19724
70d565f6e127
Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19723
diff
changeset
|
407 TriState result = binaryOpLogicNode.tryFold(infoElement.getStamp(), y.stamp()); |
70d565f6e127
Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19723
diff
changeset
|
408 if (result.isKnown()) { |
70d565f6e127
Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19723
diff
changeset
|
409 return rewireGuards(infoElement.getGuard(), result.toBoolean(), rewireGuardFunction); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
410 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
411 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
412 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
413 for (InfoElement infoElement : getInfoElements(y)) { |
19724
70d565f6e127
Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19723
diff
changeset
|
414 TriState result = binaryOpLogicNode.tryFold(x.stamp(), infoElement.getStamp()); |
70d565f6e127
Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19723
diff
changeset
|
415 if (result.isKnown()) { |
70d565f6e127
Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19723
diff
changeset
|
416 return rewireGuards(infoElement.getGuard(), result.toBoolean(), rewireGuardFunction); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
417 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
418 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
419 } else if (node instanceof ShortCircuitOrNode) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
420 final ShortCircuitOrNode shortCircuitOrNode = (ShortCircuitOrNode) node; |
19719
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
421 if (this.loopExits.isEmpty()) { |
21038
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
422 return tryProofCondition(shortCircuitOrNode.getX(), (guard, result) -> { |
19719
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
423 if (result == !shortCircuitOrNode.isXNegated()) { |
21160
0c03a7b7081f
fix in DominatorConditionalEliminationPhase for If/ShortCircuitOr with xNegated=true
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21150
diff
changeset
|
424 return rewireGuards(guard, true, rewireGuardFunction); |
19719
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
425 } else { |
21038
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
426 return tryProofCondition(shortCircuitOrNode.getY(), (innerGuard, innerResult) -> { |
19719
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
427 if (innerGuard == guard) { |
21160
0c03a7b7081f
fix in DominatorConditionalEliminationPhase for If/ShortCircuitOr with xNegated=true
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21150
diff
changeset
|
428 return rewireGuards(guard, innerResult ^ shortCircuitOrNode.isYNegated(), rewireGuardFunction); |
19719
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
429 } |
21038
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
430 return false; |
19719
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
431 }); |
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
432 } |
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
433 }); |
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
434 } |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
435 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
436 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
437 return false; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
438 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
439 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
440 private void registerNewStamp(ValueNode proxiedValue, Stamp newStamp, ValueNode guard, List<Runnable> undoOperations) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
441 if (newStamp != null) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
442 ValueNode value = GraphUtil.unproxify(proxiedValue); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
443 Info info = map.get(value); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
444 if (info == null) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
445 info = new Info(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
446 map.set(value, info); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
447 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
448 metricStampsRegistered.increment(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
449 final Info finalInfo = info; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
450 finalInfo.pushElement(new InfoElement(newStamp, guard)); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
451 undoOperations.add(() -> finalInfo.popElement()); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
452 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
453 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
454 |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
455 private void processConditionAnchor(ConditionAnchorNode node) { |
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
456 tryProofCondition(node.condition(), (guard, result) -> { |
19950
212566f9cd69
Dom-based ConditionalElimination: fix fliped check in processConditionAnchor
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
19762
diff
changeset
|
457 if (result != node.isNegated()) { |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
458 node.replaceAtUsages(guard); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
459 GraphUtil.unlinkFixedNode(node); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
460 GraphUtil.killWithUnusedFloatingInputs(node); |
19719
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
461 } else { |
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
462 ValueAnchorNode valueAnchor = node.graph().add(new ValueAnchorNode(null)); |
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
463 node.replaceAtUsages(valueAnchor); |
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
464 node.graph().replaceFixedWithFixed(node, valueAnchor); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
465 } |
21038
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
466 return true; |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
467 }); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
468 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
469 |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
470 private void processGuard(GuardNode node, List<Runnable> undoOperations) { |
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
471 if (!tryProofCondition(node.condition(), (guard, result) -> { |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
472 if (result != node.isNegated()) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
473 node.replaceAndDelete(guard); |
19719
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
474 } else { |
22872
ad106dd2000c
Fix missing transfer of speculation when recreating guards/deops
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22790
diff
changeset
|
475 DeoptimizeNode deopt = node.graph().add(new DeoptimizeNode(node.action(), node.reason(), node.getSpeculation())); |
20174
56f721367c0d
conditional elimination: use begin node from guard anchor instead of node to block map
Andreas Woess <andreas.woess@oracle.com>
parents:
20040
diff
changeset
|
476 AbstractBeginNode beginNode = (AbstractBeginNode) node.getAnchor(); |
19762
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
477 FixedNode next = beginNode.next(); |
223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19731
diff
changeset
|
478 beginNode.setNext(deopt); |
19719
055a095424a7
Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19716
diff
changeset
|
479 GraphUtil.killCFG(next); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
480 } |
21038
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
481 return true; |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
482 })) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
483 registerNewCondition(node.condition(), node.isNegated(), node, undoOperations); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
484 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
485 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
486 |
19723
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
487 private void processFixedGuard(FixedGuardNode node, List<Runnable> undoOperations) { |
1a9bfa2c3cc9
Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19721
diff
changeset
|
488 if (!tryProofCondition(node.condition(), (guard, result) -> { |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
489 if (result != node.isNegated()) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
490 node.replaceAtUsages(guard); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
491 GraphUtil.unlinkFixedNode(node); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
492 GraphUtil.killWithUnusedFloatingInputs(node); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
493 } else { |
21898
6714387f5323
Make it possible to use a speculation in a FixedGuard
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21619
diff
changeset
|
494 DeoptimizeNode deopt = node.graph().add(new DeoptimizeNode(node.getAction(), node.getReason(), node.getSpeculation())); |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
495 deopt.setStateBefore(node.stateBefore()); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
496 node.replaceAtPredecessor(deopt); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
497 GraphUtil.killCFG(node); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
498 } |
21038
6868faf48f02
Conditional Elimination: tryProofCondition: return true if ShortCircuitOrNode could be proven
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21037
diff
changeset
|
499 return true; |
19716
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
500 })) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
501 registerNewCondition(node.condition(), node.isNegated(), node, undoOperations); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
502 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
503 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
504 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
505 private void processAbstractBegin(AbstractBeginNode beginNode, List<Runnable> undoOperations) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
506 Node predecessor = beginNode.predecessor(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
507 if (predecessor instanceof IfNode) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
508 IfNode ifNode = (IfNode) predecessor; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
509 boolean negated = (ifNode.falseSuccessor() == beginNode); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
510 LogicNode condition = ifNode.condition(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
511 registerNewCondition(condition, negated, beginNode, undoOperations); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
512 } else if (predecessor instanceof TypeSwitchNode) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
513 TypeSwitchNode typeSwitch = (TypeSwitchNode) predecessor; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
514 processTypeSwitch(beginNode, undoOperations, predecessor, typeSwitch); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
515 } else if (predecessor instanceof IntegerSwitchNode) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
516 IntegerSwitchNode integerSwitchNode = (IntegerSwitchNode) predecessor; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
517 processIntegerSwitch(beginNode, undoOperations, predecessor, integerSwitchNode); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
518 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
519 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
521 private void processIntegerSwitch(AbstractBeginNode beginNode, List<Runnable> undoOperations, Node predecessor, IntegerSwitchNode integerSwitchNode) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
522 Stamp stamp = null; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
523 for (int i = 0; i < integerSwitchNode.keyCount(); i++) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
524 if (integerSwitchNode.keySuccessor(i) == predecessor) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
525 if (stamp == null) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
526 stamp = StampFactory.forConstant(integerSwitchNode.keyAt(i)); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
527 } else { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
528 stamp = stamp.meet(StampFactory.forConstant(integerSwitchNode.keyAt(i))); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
529 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
530 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
531 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
532 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
533 if (stamp != null) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
534 registerNewStamp(integerSwitchNode.value(), stamp, beginNode, undoOperations); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
535 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
536 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
537 |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
538 private void processTypeSwitch(AbstractBeginNode beginNode, List<Runnable> undoOperations, Node predecessor, TypeSwitchNode typeSwitch) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
539 ValueNode hub = typeSwitch.value(); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
540 if (hub instanceof LoadHubNode) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
541 LoadHubNode loadHub = (LoadHubNode) hub; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
542 Stamp stamp = null; |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
543 for (int i = 0; i < typeSwitch.keyCount(); i++) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
544 if (typeSwitch.keySuccessor(i) == predecessor) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
545 if (stamp == null) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
546 stamp = StampFactory.exactNonNull(typeSwitch.typeAt(i)); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
547 } else { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
548 stamp = stamp.meet(StampFactory.exactNonNull(typeSwitch.typeAt(i))); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
549 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
550 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
551 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
552 if (stamp != null) { |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
553 registerNewStamp(loadHub.getValue(), stamp, beginNode, undoOperations); |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
554 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
555 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
556 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
557 } |
2fd45bb25118
Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
558 } |