annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java @ 20931:033dd4494705

Fix compare in LoweringPhase.processBlock
author Stefan Anzinger <stefan.anzinger@oracle.com>
date Tue, 14 Apr 2015 17:23:37 +0200
parents d9713313e88c
children 953666b61a23
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19709
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
19712
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
25 import static com.oracle.graal.api.meta.DeoptimizationAction.*;
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
26 import static com.oracle.graal.api.meta.DeoptimizationReason.*;
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
27
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 import java.util.*;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 import java.util.function.*;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30
19717
70d565f6e127 Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19716
diff changeset
31 import com.oracle.graal.api.meta.*;
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
32 import com.oracle.graal.compiler.common.cfg.*;
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33 import com.oracle.graal.compiler.common.type.*;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.debug.*;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.graph.*;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 import com.oracle.graal.nodeinfo.*;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 import com.oracle.graal.nodes.*;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38 import com.oracle.graal.nodes.cfg.*;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 import com.oracle.graal.nodes.extended.*;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 import com.oracle.graal.nodes.java.*;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 import com.oracle.graal.nodes.util.*;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42 import com.oracle.graal.phases.*;
20928
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
43 import com.oracle.graal.phases.common.LoweringPhase.*;
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44 import com.oracle.graal.phases.schedule.*;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46 public class DominatorConditionalEliminationPhase extends Phase {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 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
49 private static final DebugMetric metricStampsFound = Debug.metric("StampsFound");
19714
b503dd4e723c Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19712
diff changeset
50 private final boolean fullSchedule;
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51
19714
b503dd4e723c Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19712
diff changeset
52 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: 19712
diff changeset
53 this.fullSchedule = fullSchedule;
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 private static final class InfoElement {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57 private Stamp stamp;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 private ValueNode guard;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 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
61 this.stamp = stamp;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 this.guard = guard;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 public Stamp getStamp() {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 return stamp;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 public ValueNode getGuard() {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 return guard;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 private static final class Info {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 private ArrayList<InfoElement> infos;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 public Info() {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 infos = new ArrayList<>();
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
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81 public Iterable<InfoElement> getElements() {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 return infos;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85 public void pushElement(InfoElement element) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 infos.add(element);
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
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
89 public void popElement() {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
90 infos.remove(infos.size() - 1);
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 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94 @Override
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95 protected void run(StructuredGraph graph) {
19714
b503dd4e723c Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19712
diff changeset
96
b503dd4e723c Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19712
diff changeset
97 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: 19712
diff changeset
98 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: 19712
diff changeset
99 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: 19712
diff changeset
100
b503dd4e723c Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19712
diff changeset
101 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: 19712
diff changeset
102 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: 19712
diff changeset
103 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: 19712
diff changeset
104 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: 19712
diff changeset
105 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: 19712
diff changeset
106 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: 19712
diff changeset
107 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: 19712
diff changeset
108 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: 19712
diff changeset
109 } else {
b503dd4e723c Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19712
diff changeset
110 ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, false, true, true);
b503dd4e723c Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19712
diff changeset
111 cfg.computePostdominators();
19755
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
112 BlockMap<List<FixedNode>> nodes = new BlockMap<>(cfg);
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
113 for (Block b : cfg.getBlocks()) {
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
114 ArrayList<FixedNode> curNodes = new ArrayList<>();
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
115 for (FixedNode node : b.getNodes()) {
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
116 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: 19724
diff changeset
117 curNodes.add(node);
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
118 }
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
119 }
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
120 nodes.put(b, curNodes);
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
121 }
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
122 blockToNodes = b -> nodes.get(b);
19714
b503dd4e723c Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19712
diff changeset
123 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: 19712
diff changeset
124 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: 19712
diff changeset
125 }
b503dd4e723c Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19712
diff changeset
126
b503dd4e723c Perform full schedule for conditional elimination only in a phase where floating guards are available.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19712
diff changeset
127 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: 19712
diff changeset
128 instance.processBlock(startBlock);
19709
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 private static class Instance {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 private final NodeMap<Info> map;
20040
f137f1974f60 removed uses of StringBuffer, Hashtable and Stack
Doug Simon <doug.simon@oracle.com>
parents: 19946
diff changeset
134 private final Deque<LoopExitNode> loopExits;
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 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
136 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
137
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 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
139 map = graph.createNodeMap();
20040
f137f1974f60 removed uses of StringBuffer, Hashtable and Stack
Doug Simon <doug.simon@oracle.com>
parents: 19946
diff changeset
140 loopExits = new ArrayDeque<>();
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 this.blockToNodes = blockToNodes;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142 this.nodeToBlock = nodeToBlock;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144
20928
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
145 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
146 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
147 }
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
148
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
149 public class InstanceFrame extends LoweringPhase.Frame<InstanceFrame> {
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
150 List<Runnable> undoOperations = new ArrayList<>();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
151
20928
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
152 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
153 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
154 }
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155
20928
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
156 @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
157 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
158 return new InstanceFrame(b, this);
19724
19a4fbe393d0 Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19721
diff changeset
159 }
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
160
20928
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
161 @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
162 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
163 Instance.this.preprocess(block, undoOperations);
19724
19a4fbe393d0 Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19721
diff changeset
164 }
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
165
20928
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
166 @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
167 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
168 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
169 }
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
170 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
172 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
173 for (Runnable r : undoOperations) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 r.run();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177
19724
19a4fbe393d0 Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19721
diff changeset
178 private void preprocess(Block block, List<Runnable> undoOperations) {
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 AbstractBeginNode beginNode = block.getBeginNode();
19724
19a4fbe393d0 Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19721
diff changeset
180 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: 19721
diff changeset
181 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: 19721
diff changeset
182 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: 19721
diff changeset
183 undoOperations.add(() -> loopExits.pop());
19a4fbe393d0 Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19721
diff changeset
184 }
19a4fbe393d0 Fix for conditional elimination: Block could have been deleted, but dominated block is alive.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19721
diff changeset
185 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: 19721
diff changeset
186 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: 19721
diff changeset
187 processNode(n, undoOperations);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
188 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
189 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
192 private void processNode(Node node, List<Runnable> undoOperations) {
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 if (node instanceof AbstractBeginNode) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194 processAbstractBegin((AbstractBeginNode) node, undoOperations);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195 } else if (node instanceof FixedGuardNode) {
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
196 processFixedGuard((FixedGuardNode) node, undoOperations);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
197 } else if (node instanceof GuardNode) {
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
198 processGuard((GuardNode) node, undoOperations);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
199 } else if (node instanceof CheckCastNode) {
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
200 processCheckCast((CheckCastNode) node);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
201 } else if (node instanceof ConditionAnchorNode) {
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
202 processConditionAnchor((ConditionAnchorNode) node);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
203 } else if (node instanceof IfNode) {
19755
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
204 processIf((IfNode) node, undoOperations);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
205 } else {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206 return;
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
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
210 private void processCheckCast(CheckCastNode node) {
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
211 tryProofCondition(node, (guard, result) -> {
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
212 if (result) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213 PiNode piNode = node.graph().unique(new PiNode(node.object(), node.stamp(), guard));
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
214 node.replaceAtUsages(piNode);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
215 GraphUtil.unlinkFixedNode(node);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 node.safeDelete();
19712
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
217 } else {
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
218 DeoptimizeNode deopt = node.graph().add(new DeoptimizeNode(InvalidateReprofile, UnreachedCode));
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
219 node.replaceAtPredecessor(deopt);
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
220 GraphUtil.killCFG(node);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
222 });
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
224
19755
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
225 private void processIf(IfNode node, List<Runnable> undoOperations) {
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
226 tryProofCondition(node.condition(), (guard, result) -> {
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
227 AbstractBeginNode survivingSuccessor = node.getSuccessor(result);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228 survivingSuccessor.replaceAtUsages(InputType.Guard, guard);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229 survivingSuccessor.replaceAtPredecessor(null);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230 node.replaceAtPredecessor(survivingSuccessor);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
231 GraphUtil.killCFG(node);
19721
4df907480030 Simplify begin node immediately after removing if node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19717
diff changeset
232 if (survivingSuccessor instanceof BeginNode) {
19755
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
233 undoOperations.add(() -> ((BeginNode) survivingSuccessor).trySimplify());
19721
4df907480030 Simplify begin node immediately after removing if node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19717
diff changeset
234 }
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
235 });
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
236 }
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 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
239 if (condition instanceof UnaryOpLogicNode) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
240 UnaryOpLogicNode unaryLogicNode = (UnaryOpLogicNode) condition;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241 Stamp newStamp = unaryLogicNode.getSucceedingStampForValue(negated);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 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
243 } else if (condition instanceof BinaryOpLogicNode) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244 BinaryOpLogicNode binaryOpLogicNode = (BinaryOpLogicNode) condition;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 ValueNode x = binaryOpLogicNode.getX();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246 if (!x.isConstant()) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
247 Stamp newStampX = binaryOpLogicNode.getSucceedingStampForX(negated);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
248 registerNewStamp(x, newStampX, guard, undoOperations);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
249 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
251 ValueNode y = binaryOpLogicNode.getY();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
252 if (!y.isConstant()) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
253 Stamp newStampY = binaryOpLogicNode.getSucceedingStampForY(negated);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254 registerNewStamp(y, newStampY, guard, undoOperations);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256 registerCondition(condition, negated, guard, undoOperations);
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 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
259
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260 private void registerCondition(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
261 this.registerNewStamp(condition, negated ? StampFactory.contradiction() : StampFactory.tautology(), guard, undoOperations);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
262 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
264 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
265 ValueNode value = GraphUtil.unproxify(proxiedValue);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266 Info info = map.get(value);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267 if (info == null) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
268 return Collections.emptyList();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
269 } else {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270 return info.getElements();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
271 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
272 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
273
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
274 private boolean rewireGuards(ValueNode guard, boolean result, BiConsumer<ValueNode, Boolean> rewireGuardFunction) {
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
275 assert guard instanceof GuardingNode;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
276 metricStampsFound.increment();
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
277 ValueNode proxiedGuard = proxyGuard(guard);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
278 rewireGuardFunction.accept(proxiedGuard, result);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279 return true;
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
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
282 private ValueNode proxyGuard(ValueNode guard) {
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
283 ValueNode proxiedGuard = guard;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284 if (!this.loopExits.isEmpty()) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
285 while (proxiedGuard instanceof GuardProxyNode) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286 proxiedGuard = ((GuardProxyNode) proxiedGuard).value();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
287 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
288 Block guardBlock = nodeToBlock.apply(proxiedGuard);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
289 assert guardBlock != null;
20040
f137f1974f60 removed uses of StringBuffer, Hashtable and Stack
Doug Simon <doug.simon@oracle.com>
parents: 19946
diff changeset
290 for (Iterator<LoopExitNode> iter = loopExits.descendingIterator(); iter.hasNext();) {
f137f1974f60 removed uses of StringBuffer, Hashtable and Stack
Doug Simon <doug.simon@oracle.com>
parents: 19946
diff changeset
291 LoopExitNode loopExitNode = iter.next();
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
292 Block loopExitBlock = nodeToBlock.apply(loopExitNode);
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
293 if (guardBlock != loopExitBlock && AbstractControlFlowGraph.dominates(guardBlock, loopExitBlock)) {
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
294 Block loopBeginBlock = nodeToBlock.apply(loopExitNode.loopBegin());
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
295 if (!AbstractControlFlowGraph.dominates(guardBlock, loopBeginBlock) || guardBlock == loopBeginBlock) {
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
296 proxiedGuard = proxiedGuard.graph().unique(new GuardProxyNode((GuardingNode) proxiedGuard, loopExitNode));
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
297 }
19712
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
298 }
19709
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 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
301 return proxiedGuard;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
302 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
303
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
304 private boolean tryProofCondition(Node node, BiConsumer<ValueNode, Boolean> rewireGuardFunction) {
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
305 if (node instanceof UnaryOpLogicNode) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
306 UnaryOpLogicNode unaryLogicNode = (UnaryOpLogicNode) node;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
307 ValueNode value = unaryLogicNode.getValue();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
308 for (InfoElement infoElement : getInfoElements(value)) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
309 Stamp stamp = infoElement.getStamp();
19717
70d565f6e127 Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19716
diff changeset
310 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: 19716
diff changeset
311 if (result.isKnown()) {
70d565f6e127 Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19716
diff changeset
312 return rewireGuards(infoElement.getGuard(), result.toBoolean(), rewireGuardFunction);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
313 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
314 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
315 } else if (node instanceof BinaryOpLogicNode) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
316 BinaryOpLogicNode binaryOpLogicNode = (BinaryOpLogicNode) node;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
317 for (InfoElement infoElement : getInfoElements(binaryOpLogicNode)) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
318 if (infoElement.getStamp().equals(StampFactory.contradiction())) {
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
319 return rewireGuards(infoElement.getGuard(), false, rewireGuardFunction);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320 } else if (infoElement.getStamp().equals(StampFactory.tautology())) {
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
321 return rewireGuards(infoElement.getGuard(), true, rewireGuardFunction);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
322 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
323 }
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 ValueNode x = binaryOpLogicNode.getX();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
326 ValueNode y = binaryOpLogicNode.getY();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
327 for (InfoElement infoElement : getInfoElements(x)) {
19717
70d565f6e127 Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19716
diff changeset
328 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: 19716
diff changeset
329 if (result.isKnown()) {
70d565f6e127 Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19716
diff changeset
330 return rewireGuards(infoElement.getGuard(), result.toBoolean(), rewireGuardFunction);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
331 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
332 }
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 for (InfoElement infoElement : getInfoElements(y)) {
19717
70d565f6e127 Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19716
diff changeset
335 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: 19716
diff changeset
336 if (result.isKnown()) {
70d565f6e127 Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19716
diff changeset
337 return rewireGuards(infoElement.getGuard(), result.toBoolean(), rewireGuardFunction);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
338 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
339 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
340 } else if (node instanceof CheckCastNode) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
341 CheckCastNode checkCastNode = (CheckCastNode) node;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
342 for (InfoElement infoElement : getInfoElements(checkCastNode.object())) {
19717
70d565f6e127 Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19716
diff changeset
343 TriState result = checkCastNode.tryFold(infoElement.getStamp());
70d565f6e127 Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19716
diff changeset
344 if (result.isKnown()) {
70d565f6e127 Convert API for tryFold from Boolean return value to TriState return value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19716
diff changeset
345 return rewireGuards(infoElement.getGuard(), result.toBoolean(), rewireGuardFunction);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
346 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
347 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
348 } else if (node instanceof ShortCircuitOrNode) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
349 final ShortCircuitOrNode shortCircuitOrNode = (ShortCircuitOrNode) node;
19712
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
350 if (this.loopExits.isEmpty()) {
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
351 tryProofCondition(shortCircuitOrNode.getX(), (guard, result) -> {
19712
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
352 if (result == !shortCircuitOrNode.isXNegated()) {
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
353 rewireGuards(guard, result, rewireGuardFunction);
19712
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
354 } else {
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
355 tryProofCondition(shortCircuitOrNode.getY(), (innerGuard, innerResult) -> {
19712
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
356 if (innerGuard == guard) {
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
357 rewireGuards(guard, shortCircuitOrNode.isYNegated() ? !innerResult : innerResult, rewireGuardFunction);
19712
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
358 }
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
359 });
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
360 }
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
361 });
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
362 }
19709
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
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
365 return false;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
366 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
367
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368 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
369 if (newStamp != null) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
370 ValueNode value = GraphUtil.unproxify(proxiedValue);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
371 Info info = map.get(value);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
372 if (info == null) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
373 info = new Info();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
374 map.set(value, info);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
375 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376 metricStampsRegistered.increment();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
377 final Info finalInfo = info;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
378 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
379 undoOperations.add(() -> finalInfo.popElement());
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
380 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
381 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
382
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
383 private void processConditionAnchor(ConditionAnchorNode node) {
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
384 tryProofCondition(node.condition(), (guard, result) -> {
19946
212566f9cd69 Dom-based ConditionalElimination: fix fliped check in processConditionAnchor
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19755
diff changeset
385 if (result != node.isNegated()) {
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
386 node.replaceAtUsages(guard);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387 GraphUtil.unlinkFixedNode(node);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 GraphUtil.killWithUnusedFloatingInputs(node);
19712
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
389 } else {
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
390 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: 19709
diff changeset
391 node.replaceAtUsages(valueAnchor);
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
392 node.graph().replaceFixedWithFixed(node, valueAnchor);
19709
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 });
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
395 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
396
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
397 private void processGuard(GuardNode node, List<Runnable> undoOperations) {
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
398 if (!tryProofCondition(node.condition(), (guard, result) -> {
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 if (result != node.isNegated()) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
400 node.replaceAndDelete(guard);
19712
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
401 } else {
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
402 DeoptimizeNode deopt = node.graph().add(new DeoptimizeNode(node.action(), node.reason()));
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
403 AbstractBeginNode beginNode = (AbstractBeginNode) node.getAnchor();
19755
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
404 FixedNode next = beginNode.next();
223e1d7b15b7 Make conditional elimination more robust wrt deleted begin nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19724
diff changeset
405 beginNode.setNext(deopt);
19712
055a095424a7 Fixes for new conditional elimination phase. Make it default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19709
diff changeset
406 GraphUtil.killCFG(next);
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
407 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
408 })) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409 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
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
19716
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
413 private void processFixedGuard(FixedGuardNode node, List<Runnable> undoOperations) {
1a9bfa2c3cc9 Reduce number of inserted guard proxies.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19714
diff changeset
414 if (!tryProofCondition(node.condition(), (guard, result) -> {
19709
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
415 if (result != node.isNegated()) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
416 node.replaceAtUsages(guard);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
417 GraphUtil.unlinkFixedNode(node);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
418 GraphUtil.killWithUnusedFloatingInputs(node);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
419 } else {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
420 DeoptimizeNode deopt = node.graph().add(new DeoptimizeNode(node.getAction(), node.getReason()));
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
421 deopt.setStateBefore(node.stateBefore());
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
422 node.replaceAtPredecessor(deopt);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
423 GraphUtil.killCFG(node);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
424 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
425 })) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
426 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
427 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
428 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
429
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
430 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
431 Node predecessor = beginNode.predecessor();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
432 if (predecessor instanceof IfNode) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
433 IfNode ifNode = (IfNode) predecessor;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434 boolean negated = (ifNode.falseSuccessor() == beginNode);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
435 LogicNode condition = ifNode.condition();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436 registerNewCondition(condition, negated, beginNode, undoOperations);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
437 } else if (predecessor instanceof TypeSwitchNode) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438 TypeSwitchNode typeSwitch = (TypeSwitchNode) predecessor;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
439 processTypeSwitch(beginNode, undoOperations, predecessor, typeSwitch);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
440 } else if (predecessor instanceof IntegerSwitchNode) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
441 IntegerSwitchNode integerSwitchNode = (IntegerSwitchNode) predecessor;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
442 processIntegerSwitch(beginNode, undoOperations, predecessor, integerSwitchNode);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
443 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
444 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
446 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
447 Stamp stamp = null;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
448 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
449 if (integerSwitchNode.keySuccessor(i) == predecessor) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
450 if (stamp == null) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
451 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
452 } else {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
453 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
454 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
455 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
456 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
457
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
458 if (stamp != null) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
459 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
460 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
461 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
462
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
463 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
464 ValueNode hub = typeSwitch.value();
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
465 if (hub instanceof LoadHubNode) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
466 LoadHubNode loadHub = (LoadHubNode) hub;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
467 Stamp stamp = null;
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468 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
469 if (typeSwitch.keySuccessor(i) == predecessor) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
470 if (stamp == null) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
471 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
472 } else {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
473 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
474 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
475 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
476 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
477 if (stamp != null) {
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478 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
479 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
480 }
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
481 }
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 }