Mercurial > hg > truffle
annotate graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java @ 19513:cb59c8b7da46
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 19 Feb 2015 23:40:21 +0100 |
parents | caad3adc5fde 1cde96b96673 |
children | dba496fc044a |
rev | line source |
---|---|
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
1 /* |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
4 * |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
8 * |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
14 * |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
18 * |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
21 * questions. |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
22 */ |
6523
c8763a2deb0c
rename packages in graal.loop to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6522
diff
changeset
|
23 package com.oracle.graal.loop; |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
24 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
25 import java.util.*; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
26 |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15151
diff
changeset
|
27 import com.oracle.graal.compiler.common.*; |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
28 import com.oracle.graal.graph.*; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
29 import com.oracle.graal.graph.Graph.DuplicationReplacement; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
30 import com.oracle.graal.graph.iterators.*; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
31 import com.oracle.graal.nodes.*; |
6529
2e96dc4eb8e2
renamed package: com.oracle.graal.lir.cfg -> com.oracle.graal.nodes.cfg
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
32 import com.oracle.graal.nodes.cfg.*; |
13554
83fd2094ff66
rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents:
13327
diff
changeset
|
33 import com.oracle.graal.nodes.java.*; |
15209
f52e47b757b9
Loop transform: mark states from all NodeWithStates not just StateSplit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15204
diff
changeset
|
34 import com.oracle.graal.nodes.spi.*; |
12479
36a438ebab50
duplicate VirtualObjectNodes when peeling / unrolling loops
Lukas Stadler <lukas.stadler@jku.at>
parents:
12437
diff
changeset
|
35 import com.oracle.graal.nodes.virtual.*; |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
36 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6709
diff
changeset
|
37 public abstract class LoopFragment { |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
38 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
39 private final LoopEx loop; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
40 private final LoopFragment original; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
41 protected NodeBitMap nodes; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
42 protected boolean nodesReady; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
43 private Map<Node, Node> duplicationMap; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
44 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
45 public LoopFragment(LoopEx loop) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
46 this(loop, null); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
47 this.nodesReady = true; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
48 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
49 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
50 public LoopFragment(LoopEx loop, LoopFragment original) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
51 this.loop = loop; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
52 this.original = original; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
53 this.nodesReady = false; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
54 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
55 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
56 public LoopEx loop() { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
57 return loop; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
58 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
59 |
16059
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
60 public abstract LoopFragment duplicate(); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
61 |
16059
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
62 public abstract void insertBefore(LoopEx l); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
63 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
64 public void disconnect() { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
65 // TODO (gd) possibly abstract |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
66 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
67 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
68 public boolean contains(Node n) { |
15956
edc33e8715d5
NodeWorkList refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15955
diff
changeset
|
69 return nodes().isMarkedAndGrow(n); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
70 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
71 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
72 @SuppressWarnings("unchecked") |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
73 public <New extends Node, Old extends New> New getDuplicatedNode(Old n) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
74 assert isDuplicate(); |
13327
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13152
diff
changeset
|
75 return (New) duplicationMap.get(n); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
76 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
77 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
78 protected <New extends Node, Old extends New> void putDuplicatedNode(Old oldNode, New newNode) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
79 duplicationMap.put(oldNode, newNode); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
80 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
81 |
15143
c68064651847
Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14995
diff
changeset
|
82 /** |
c68064651847
Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14995
diff
changeset
|
83 * Gets the corresponding value in this fragment. Should be called on duplicate fragments with a |
c68064651847
Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14995
diff
changeset
|
84 * node from the original fragment as argument. |
c68064651847
Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14995
diff
changeset
|
85 * |
c68064651847
Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14995
diff
changeset
|
86 * @param b original value |
c68064651847
Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14995
diff
changeset
|
87 * @return corresponding value in the peel |
c68064651847
Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14995
diff
changeset
|
88 */ |
c68064651847
Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14995
diff
changeset
|
89 protected abstract ValueNode prim(ValueNode b); |
c68064651847
Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14995
diff
changeset
|
90 |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
91 public boolean isDuplicate() { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
92 return original != null; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
93 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
94 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
95 public LoopFragment original() { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
96 return original; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
97 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
98 |
15956
edc33e8715d5
NodeWorkList refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15955
diff
changeset
|
99 public abstract NodeBitMap nodes(); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
100 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
101 public StructuredGraph graph() { |
5741
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
102 LoopEx l; |
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
103 if (isDuplicate()) { |
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
104 l = original().loop(); |
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
105 } else { |
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
106 l = loop(); |
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
107 } |
9602
19c5a07c7843
Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9600
diff
changeset
|
108 return l.loopBegin().graph(); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
109 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
110 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
111 protected abstract DuplicationReplacement getDuplicationReplacement(); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
112 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
113 protected abstract void finishDuplication(); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
114 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
115 protected void patchNodes(final DuplicationReplacement dataFix) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
116 if (isDuplicate() && !nodesReady) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
117 assert !original.isDuplicate(); |
5741
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
118 final DuplicationReplacement cfgFix = original().getDuplicationReplacement(); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
119 DuplicationReplacement dr; |
5741
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
120 if (cfgFix == null && dataFix != null) { |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
121 dr = dataFix; |
5741
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
122 } else if (cfgFix != null && dataFix == null) { |
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
123 dr = cfgFix; |
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
124 } else if (cfgFix != null && dataFix != null) { |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
125 dr = new DuplicationReplacement() { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6709
diff
changeset
|
126 |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
127 @Override |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
128 public Node replacement(Node o) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
129 Node r1 = dataFix.replacement(o); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
130 if (r1 != o) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
131 assert cfgFix.replacement(o) == o; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
132 return r1; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
133 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
134 Node r2 = cfgFix.replacement(o); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
135 if (r2 != o) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
136 return r2; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
137 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
138 return o; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
139 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
140 }; |
5741
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
141 } else { |
11671
3522f7c99c5f
Allow null DuplicationReplacement in addDuplicates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11652
diff
changeset
|
142 dr = null; |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
143 } |
11675
77d9f12797c5
Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11671
diff
changeset
|
144 NodeIterable<Node> nodesIterable = original().nodes(); |
77d9f12797c5
Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11671
diff
changeset
|
145 duplicationMap = graph().addDuplicates(nodesIterable, graph(), nodesIterable.count(), dr); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
146 finishDuplication(); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
147 nodesReady = true; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
148 } else { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6709
diff
changeset
|
149 // TODO (gd) apply fix ? |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
150 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
151 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
152 |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
153 protected static NodeBitMap computeNodes(Graph graph, Iterable<AbstractBeginNode> blocks) { |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
154 return computeNodes(graph, blocks, Collections.emptyList()); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
155 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
156 |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
157 protected static NodeBitMap computeNodes(Graph graph, Iterable<AbstractBeginNode> blocks, Iterable<LoopExitNode> earlyExits) { |
15955
3f48e9a1016c
NodeBitMap refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15534
diff
changeset
|
158 final NodeBitMap nodes = graph.createNodeBitMap(); |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
159 for (AbstractBeginNode b : blocks) { |
12750
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
160 if (b.isDeleted()) { |
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
161 continue; |
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
162 } |
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
163 |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
164 for (Node n : b.getBlockNodes()) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
165 if (n instanceof Invoke) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
166 nodes.mark(((Invoke) n).callTarget()); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
167 } |
15209
f52e47b757b9
Loop transform: mark states from all NodeWithStates not just StateSplit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15204
diff
changeset
|
168 if (n instanceof NodeWithState) { |
f52e47b757b9
Loop transform: mark states from all NodeWithStates not just StateSplit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15204
diff
changeset
|
169 NodeWithState withState = (NodeWithState) n; |
f52e47b757b9
Loop transform: mark states from all NodeWithStates not just StateSplit
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15204
diff
changeset
|
170 withState.states().forEach(state -> state.applyToVirtual(node -> nodes.mark(node))); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
171 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
172 nodes.mark(n); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
173 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
174 } |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
175 for (LoopExitNode earlyExit : earlyExits) { |
12750
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
176 if (earlyExit.isDeleted()) { |
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
177 continue; |
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
178 } |
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
179 |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
180 FrameState stateAfter = earlyExit.stateAfter(); |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5519
diff
changeset
|
181 if (stateAfter != null) { |
15204
4d19ee79fcee
Fix loop peeling problem with VirtualState: duplicate states deeply and only clear the parts of the exit's state that's not used by the duplicated nodes.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15193
diff
changeset
|
182 stateAfter.applyToVirtual(node -> nodes.mark(node)); |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5519
diff
changeset
|
183 } |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
184 nodes.mark(earlyExit); |
7897
a58851061377
rename ValueProxyNode to ProxyNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
185 for (ProxyNode proxy : earlyExit.proxies()) { |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
186 nodes.mark(proxy); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
187 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
188 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
189 |
15955
3f48e9a1016c
NodeBitMap refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15534
diff
changeset
|
190 final NodeBitMap notloopNodes = graph.createNodeBitMap(); |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
191 for (AbstractBeginNode b : blocks) { |
12750
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
192 if (b.isDeleted()) { |
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
193 continue; |
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
194 } |
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
195 |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
196 for (Node n : b.getBlockNodes()) { |
12479
36a438ebab50
duplicate VirtualObjectNodes when peeling / unrolling loops
Lukas Stadler <lukas.stadler@jku.at>
parents:
12437
diff
changeset
|
197 if (n instanceof CommitAllocationNode) { |
36a438ebab50
duplicate VirtualObjectNodes when peeling / unrolling loops
Lukas Stadler <lukas.stadler@jku.at>
parents:
12437
diff
changeset
|
198 for (VirtualObjectNode obj : ((CommitAllocationNode) n).getVirtualObjects()) { |
36a438ebab50
duplicate VirtualObjectNodes when peeling / unrolling loops
Lukas Stadler <lukas.stadler@jku.at>
parents:
12437
diff
changeset
|
199 markFloating(obj, nodes, notloopNodes); |
36a438ebab50
duplicate VirtualObjectNodes when peeling / unrolling loops
Lukas Stadler <lukas.stadler@jku.at>
parents:
12437
diff
changeset
|
200 } |
36a438ebab50
duplicate VirtualObjectNodes when peeling / unrolling loops
Lukas Stadler <lukas.stadler@jku.at>
parents:
12437
diff
changeset
|
201 } |
13554
83fd2094ff66
rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents:
13327
diff
changeset
|
202 if (n instanceof MonitorEnterNode) { |
83fd2094ff66
rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents:
13327
diff
changeset
|
203 markFloating(((MonitorEnterNode) n).getMonitorId(), nodes, notloopNodes); |
83fd2094ff66
rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents:
13327
diff
changeset
|
204 } |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
205 for (Node usage : n.usages()) { |
9600
20c09d314168
Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9436
diff
changeset
|
206 markFloating(usage, nodes, notloopNodes); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
207 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
208 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
209 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
210 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
211 return nodes; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
212 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
213 |
9600
20c09d314168
Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9436
diff
changeset
|
214 private static boolean markFloating(Node n, NodeBitMap loopNodes, NodeBitMap notloopNodes) { |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
215 if (loopNodes.isMarked(n)) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
216 return true; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
217 } |
9600
20c09d314168
Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9436
diff
changeset
|
218 if (notloopNodes.isMarked(n)) { |
20c09d314168
Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9436
diff
changeset
|
219 return false; |
20c09d314168
Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9436
diff
changeset
|
220 } |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
221 if (n instanceof FixedNode) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
222 return false; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
223 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
224 boolean mark = false; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
225 if (n instanceof PhiNode) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
226 PhiNode phi = (PhiNode) n; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
227 mark = loopNodes.isMarked(phi.merge()); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
228 if (mark) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
229 loopNodes.mark(n); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
230 } else { |
9600
20c09d314168
Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9436
diff
changeset
|
231 notloopNodes.mark(n); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
232 return false; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
233 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
234 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
235 for (Node usage : n.usages()) { |
9600
20c09d314168
Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9436
diff
changeset
|
236 if (markFloating(usage, loopNodes, notloopNodes)) { |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
237 mark = true; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
238 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
239 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
240 if (mark) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
241 loopNodes.mark(n); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
242 return true; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
243 } |
9600
20c09d314168
Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9436
diff
changeset
|
244 notloopNodes.mark(n); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
245 return false; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
246 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
247 |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
248 public static NodeIterable<AbstractBeginNode> toHirBlocks(final Iterable<Block> blocks) { |
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
249 return new NodeIterable<AbstractBeginNode>() { |
11522
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
250 |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
251 public Iterator<AbstractBeginNode> iterator() { |
11522
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
252 final Iterator<Block> it = blocks.iterator(); |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
253 return new Iterator<AbstractBeginNode>() { |
11522
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
254 |
12437
c991f8291f1b
add missing @Override to Iterator.remove overrides
twisti
parents:
11675
diff
changeset
|
255 @Override |
11522
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
256 public void remove() { |
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
257 throw new UnsupportedOperationException(); |
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
258 } |
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
259 |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
260 public AbstractBeginNode next() { |
11522
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
261 return it.next().getBeginNode(); |
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
262 } |
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
263 |
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
264 public boolean hasNext() { |
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
265 return it.hasNext(); |
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
266 } |
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
267 }; |
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
268 } |
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
269 |
dbf968195ca1
use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9602
diff
changeset
|
270 }; |
5732
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5713
diff
changeset
|
271 } |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5713
diff
changeset
|
272 |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
273 public static NodeIterable<LoopExitNode> toHirExits(final Iterable<Block> blocks) { |
15146
65efd2eeea1b
Remove AbstractNodeIterable, move its methods to default methods on NodeIterable.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15145
diff
changeset
|
274 return new NodeIterable<LoopExitNode>() { |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
275 |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
276 public Iterator<LoopExitNode> iterator() { |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
277 final Iterator<Block> it = blocks.iterator(); |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
278 return new Iterator<LoopExitNode>() { |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
279 |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
280 @Override |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
281 public void remove() { |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
282 throw new UnsupportedOperationException(); |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
283 } |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
284 |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
285 public LoopExitNode next() { |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
286 return (LoopExitNode) it.next().getBeginNode(); |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
287 } |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
288 |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
289 public boolean hasNext() { |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
290 return it.hasNext(); |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
291 } |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
292 }; |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
293 } |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
294 |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
295 }; |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
296 } |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
297 |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
298 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6709
diff
changeset
|
299 * Merges the early exits (i.e. loop exits) that were duplicated as part of this fragment, with |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6709
diff
changeset
|
300 * the original fragment's exits. |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
301 */ |
16059
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
302 protected void mergeEarlyExits() { |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
303 assert isDuplicate(); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
304 StructuredGraph graph = graph(); |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
305 for (AbstractBeginNode earlyExit : LoopFragment.toHirBlocks(original().loop().loop().getExits())) { |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
306 LoopExitNode loopEarlyExit = (LoopExitNode) earlyExit; |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
307 FixedNode next = loopEarlyExit.next(); |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
308 if (loopEarlyExit.isDeleted() || !this.original().contains(loopEarlyExit)) { |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
309 continue; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
310 } |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
311 AbstractBeginNode newEarlyExit = getDuplicatedNode(loopEarlyExit); |
5741
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
312 if (newEarlyExit == null) { |
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
313 continue; |
c84c75339af1
Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5732
diff
changeset
|
314 } |
19509
caad3adc5fde
Change forward ends to type EndNode and not AbstractEndNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18996
diff
changeset
|
315 MergeNode merge = graph.add(new MergeNode()); |
caad3adc5fde
Change forward ends to type EndNode and not AbstractEndNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18996
diff
changeset
|
316 EndNode originalEnd = graph.add(new EndNode()); |
caad3adc5fde
Change forward ends to type EndNode and not AbstractEndNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18996
diff
changeset
|
317 EndNode newEnd = graph.add(new EndNode()); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
318 merge.addForwardEnd(originalEnd); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
319 merge.addForwardEnd(newEnd); |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
320 loopEarlyExit.setNext(originalEnd); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
321 newEarlyExit.setNext(newEnd); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
322 merge.setNext(next); |
5639
d1d649d2f97c
set correct probabilities on MergeNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
5612
diff
changeset
|
323 |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
324 FrameState exitState = loopEarlyExit.stateAfter(); |
5519
cedae73d9c2a
Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5489
diff
changeset
|
325 if (exitState != null) { |
16349
5a3351bb88a8
Minor refactoring in LoopFragment.mergeEarlyExits to improve readability
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16191
diff
changeset
|
326 FrameState originalExitState = exitState; |
16059
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
327 exitState = exitState.duplicateWithVirtualState(); |
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
328 loopEarlyExit.setStateAfter(exitState); |
16349
5a3351bb88a8
Minor refactoring in LoopFragment.mergeEarlyExits to improve readability
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16191
diff
changeset
|
329 merge.setStateAfter(originalExitState); |
16059
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
330 /* |
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
331 * Using the old exit's state as the merge's state is necessary because some of the |
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
332 * VirtualState nodes contained in the old exit's state may be shared by other |
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
333 * dominated VirtualStates. Those dominated virtual states need to see the |
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
334 * proxy->phi update that are applied below. |
19507
1cde96b96673
Fixed code format issues.
Roland Schatz <roland.schatz@oracle.com>
parents:
18996
diff
changeset
|
335 * |
16059
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
336 * We now update the original fragment's nodes accordingly: |
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
337 */ |
16349
5a3351bb88a8
Minor refactoring in LoopFragment.mergeEarlyExits to improve readability
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16191
diff
changeset
|
338 originalExitState.applyToVirtual(node -> original.nodes.clearAndGrow(node)); |
16059
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
339 exitState.applyToVirtual(node -> original.nodes.markAndGrow(node)); |
5519
cedae73d9c2a
Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5489
diff
changeset
|
340 } |
15151
1dc1af3bf402
use node.replaceAtMatchingUsages in LoopFragment.mergeEarlyExits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
341 FrameState finalExitState = exitState; |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
342 |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
343 for (Node anchored : loopEarlyExit.anchored().snapshot()) { |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
344 anchored.replaceFirstInput(loopEarlyExit, merge); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
345 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
346 |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
347 boolean newEarlyExitIsLoopExit = newEarlyExit instanceof LoopExitNode; |
16561
ca2b422e8f50
Remove unnecessary final
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16459
diff
changeset
|
348 for (ProxyNode vpn : loopEarlyExit.proxies().snapshot()) { |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
349 if (vpn.hasNoUsages()) { |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
350 continue; |
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
351 } |
5713
8c478272fb34
Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5678
diff
changeset
|
352 final ValueNode replaceWith; |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
353 ValueNode newVpn = prim(newEarlyExitIsLoopExit ? vpn : vpn.value()); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
354 if (newVpn != null) { |
13152
640516a8ca6b
Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
355 PhiNode phi; |
14978
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14826
diff
changeset
|
356 if (vpn instanceof ValueProxyNode) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18669
diff
changeset
|
357 phi = graph.addWithoutUnique(new ValuePhiNode(vpn.stamp(), merge)); |
14978
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14826
diff
changeset
|
358 } else if (vpn instanceof GuardProxyNode) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18669
diff
changeset
|
359 phi = graph.addWithoutUnique(new GuardPhiNode(merge)); |
14978
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14826
diff
changeset
|
360 } else { |
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14826
diff
changeset
|
361 throw GraalInternalError.shouldNotReachHere(); |
13152
640516a8ca6b
Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
362 } |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
363 phi.addInput(vpn); |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15143
diff
changeset
|
364 phi.addInput(newVpn); |
5598
a9b615da0cba
removed delta-encoding of VirtualObjectState
Lukas Stadler <lukas.stadler@jku.at>
parents:
5519
diff
changeset
|
365 replaceWith = phi; |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
366 } else { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
367 replaceWith = vpn.value(); |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
368 } |
15151
1dc1af3bf402
use node.replaceAtMatchingUsages in LoopFragment.mergeEarlyExits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
369 vpn.replaceAtMatchingUsages(replaceWith, usage -> { |
1dc1af3bf402
use node.replaceAtMatchingUsages in LoopFragment.mergeEarlyExits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
370 if (merge.isPhiAtMerge(usage)) { |
1dc1af3bf402
use node.replaceAtMatchingUsages in LoopFragment.mergeEarlyExits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
371 return false; |
1dc1af3bf402
use node.replaceAtMatchingUsages in LoopFragment.mergeEarlyExits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
372 } |
16059
bab1a955411e
Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16038
diff
changeset
|
373 if (usage instanceof VirtualState) { |
15151
1dc1af3bf402
use node.replaceAtMatchingUsages in LoopFragment.mergeEarlyExits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
374 VirtualState stateUsage = (VirtualState) usage; |
1dc1af3bf402
use node.replaceAtMatchingUsages in LoopFragment.mergeEarlyExits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
375 if (finalExitState.isPartOfThisState(stateUsage)) { |
1dc1af3bf402
use node.replaceAtMatchingUsages in LoopFragment.mergeEarlyExits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
376 return false; |
5713
8c478272fb34
Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5678
diff
changeset
|
377 } |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
378 } |
15151
1dc1af3bf402
use node.replaceAtMatchingUsages in LoopFragment.mergeEarlyExits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
379 return true; |
1dc1af3bf402
use node.replaceAtMatchingUsages in LoopFragment.mergeEarlyExits
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
380 }); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
381 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
382 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
383 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
384 } |