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