annotate graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java @ 18383:1518c3296cc8

use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
author Doug Simon <doug.simon@oracle.com>
date Sun, 16 Nov 2014 09:44:04 +0100
parents 06c15e88d383
children 220d7f242e57
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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: 15145
diff changeset
27 import com.oracle.graal.compiler.common.*;
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
28 import com.oracle.graal.graph.*;
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
29 import com.oracle.graal.graph.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
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.*;
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
32 import com.oracle.graal.nodes.VirtualState.*;
16350
6055f84e41d7 LoopFragmentInside: make sure no dead phi are left after phis have been rewritten
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16059
diff changeset
33 import com.oracle.graal.nodes.util.*;
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
34
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
35 public class LoopFragmentInside extends 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
36
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
37 /**
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
38 * mergedInitializers. When an inside fragment's (loop)ends are merged to create a unique exit
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
39 * point, some phis must be created : they phis together all the back-values of the loop-phis
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
40 * These can then be used to update the loop-phis' forward edge value ('initializer') in the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
41 * peeling case. In the unrolling case they will be used as the value that replace the loop-phis
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
42 * of the duplicated inside fragment
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
43 */
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
44 private Map<ValuePhiNode, ValueNode> mergedInitializers;
5741
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
45 private final DuplicationReplacement dataFixBefore = new DuplicationReplacement() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
46
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
47 @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
48 public Node replacement(Node oriInput) {
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 if (!(oriInput instanceof ValueNode)) {
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 return oriInput;
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 }
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 return prim((ValueNode) oriInput);
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 }
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 LoopFragmentInside(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 super(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
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
60 public LoopFragmentInside(LoopFragmentInside original) {
5741
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
61 super(null, original);
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
62 }
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 @Override
16059
bab1a955411e Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16038
diff changeset
65 public LoopFragmentInside 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
66 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
67 return new LoopFragmentInside(this);
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 }
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
69
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 @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
71 public LoopFragmentInside 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
72 return (LoopFragmentInside) super.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
73 }
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
5498
eb0d4946a1ea Fix compiler warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5489
diff changeset
75 @SuppressWarnings("unused")
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 public void appendInside(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
77 // TODO (gd)
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 }
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
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 @Override
5741
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
81 public LoopEx loop() {
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
82 assert !this.isDuplicate();
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
83 return super.loop();
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
84 }
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
85
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
86 @Override
16059
bab1a955411e Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16038
diff changeset
87 public void insertBefore(LoopEx loop) {
5741
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
88 assert this.isDuplicate() && this.original().loop() == loop;
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
89
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
90 patchNodes(dataFixBefore);
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
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
92 BeginNode end = mergeEnds();
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
93
16059
bab1a955411e Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16038
diff changeset
94 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
95
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
96 original().patchPeeling(this);
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
97
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
98 BeginNode entry = getDuplicatedNode(loop.loopBegin());
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
99 loop.entryPoint().replaceAtPredecessor(entry);
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 end.setNext(loop.entryPoint());
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 }
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
102
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
103 @Override
15956
edc33e8715d5 NodeWorkList refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15955
diff changeset
104 public 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
105 if (nodes == 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
106 LoopFragmentWhole whole = loop().whole();
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
107 whole.nodes(); // init nodes bitmap in whole
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
108 nodes = whole.nodes.copy();
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
109 // remove the phis
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
110 LoopBeginNode loopBegin = loop().loopBegin();
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
111 for (PhiNode phi : loopBegin.phis()) {
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
112 nodes.clear(phi);
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 }
16351
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
114 clearStateNodes(loopBegin);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
115 for (LoopExitNode exit : exits()) {
16351
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
116 clearStateNodes(exit);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
117 for (ProxyNode proxy : exit.proxies()) {
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
118 nodes.clear(proxy);
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
119 }
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
120 }
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 }
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
122 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
123 }
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
124
16351
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
125 private void clearStateNodes(StateSplit stateSplit) {
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
126 FrameState loopState = stateSplit.stateAfter();
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
127 if (loopState != null) {
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
128 loopState.applyToVirtual(v -> {
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
129 if (v.usages().filter(n -> nodes.isMarked(n) && n != stateSplit).isEmpty()) {
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
130 nodes.clear(v);
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
131 }
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
132 });
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
133 }
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
134 }
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
135
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
136 public NodeIterable<LoopExitNode> exits() {
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
137 return loop().loopBegin().loopExits();
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
138 }
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
139
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
140 @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
141 protected 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
142 final LoopBeginNode loopBegin = loop().loopBegin();
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 final StructuredGraph graph = 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
144 return new DuplicationReplacement() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
145
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
146 private Map<Node, Node> seenNode = Node.newMap();
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
147
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
148 @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
149 public Node replacement(Node 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
150 if (original == loopBegin) {
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
151 Node value = seenNode.get(original);
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
152 if (value != null) {
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
153 return value;
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
154 }
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16351
diff changeset
155 BeginNode newValue = graph.add(BeginNode.create());
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
156 seenNode.put(original, newValue);
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
157 return newValue;
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
158 }
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
159 if (original instanceof LoopExitNode && ((LoopExitNode) original).loopBegin() == loopBegin) {
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
160 Node value = seenNode.get(original);
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
161 if (value != null) {
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
162 return value;
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
163 }
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16351
diff changeset
164 BeginNode newValue = graph.add(BeginNode.create());
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
165 seenNode.put(original, newValue);
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
166 return newValue;
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
167 }
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
168 if (original instanceof LoopEndNode && ((LoopEndNode) original).loopBegin() == loopBegin) {
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
169 Node value = seenNode.get(original);
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
170 if (value != null) {
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
171 return value;
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
172 }
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16351
diff changeset
173 EndNode newValue = graph.add(EndNode.create());
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
174 seenNode.put(original, newValue);
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
175 return newValue;
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
176 }
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
177 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
178 }
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
179 };
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 }
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
181
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
182 @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
183 protected 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
184 // TODO (gd) ?
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
185 }
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
13152
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 11669
diff changeset
187 private static PhiNode patchPhi(StructuredGraph graph, PhiNode phi, MergeNode merge) {
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 11669
diff changeset
188 PhiNode ret;
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
189 if (phi instanceof ValuePhiNode) {
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16351
diff changeset
190 ret = ValuePhiNode.create(phi.stamp(), merge);
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
191 } else if (phi instanceof GuardPhiNode) {
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16351
diff changeset
192 ret = GuardPhiNode.create(merge);
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
193 } else if (phi instanceof MemoryPhiNode) {
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16351
diff changeset
194 ret = MemoryPhiNode.create(merge, ((MemoryPhiNode) phi).getLocationIdentity());
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
195 } else {
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
196 throw GraalInternalError.shouldNotReachHere();
13152
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 11669
diff changeset
197 }
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 11669
diff changeset
198 return graph.addWithoutUnique(ret);
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 11669
diff changeset
199 }
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 11669
diff changeset
200
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
201 private void patchPeeling(LoopFragmentInside peel) {
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
202 LoopBeginNode loopBegin = loop().loopBegin();
9602
19c5a07c7843 Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9436
diff changeset
203 StructuredGraph graph = 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
204 List<PhiNode> newPhis = new LinkedList<>();
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
205
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
206 NodeBitMap usagesToPatch = nodes.copy();
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
207 for (LoopExitNode exit : exits()) {
16351
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
208 markStateNodes(exit, usagesToPatch);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
209 for (ProxyNode proxy : exit.proxies()) {
15955
3f48e9a1016c NodeBitMap refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15551
diff changeset
210 usagesToPatch.markAndGrow(proxy);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
211 }
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
212 }
16351
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
213 markStateNodes(loopBegin, usagesToPatch);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
214
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 for (PhiNode phi : loopBegin.phis().snapshot()) {
15144
76695509b2fd Avoid precessing unused phis during peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
216 if (phi.usages().isEmpty()) {
76695509b2fd Avoid precessing unused phis during peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
217 continue;
76695509b2fd Avoid precessing unused phis during peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
218 }
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
219 ValueNode first;
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
220 if (loopBegin.loopEnds().count() == 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
221 ValueNode b = phi.valueAt(loopBegin.loopEnds().first()); // back edge 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
222 first = peel.prim(b); // corresponding value in the peel
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 } 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
224 first = peel.mergedInitializers.get(phi);
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 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
226 // create a new phi (we don't patch the old one since some usages of the old one may
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
227 // still be valid)
13152
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 11669
diff changeset
228 PhiNode newPhi = patchPhi(graph, phi, loopBegin);
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
229 newPhi.addInput(first);
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 for (LoopEndNode end : loopBegin.orderedLoopEnds()) {
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
231 newPhi.addInput(phi.valueAt(end));
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 }
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 peel.putDuplicatedNode(phi, newPhi);
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 newPhis.add(newPhi);
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 : phi.usages().snapshot()) {
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
236 // patch only usages that should use the new phi ie usages that were peeled
15955
3f48e9a1016c NodeBitMap refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15551
diff changeset
237 if (usagesToPatch.isMarkedAndGrow(usage)) {
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
238 usage.replaceFirstInput(phi, newPhi);
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 }
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 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
242 // check new phis to see if they have as input some old phis, replace those inputs with the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
243 // new corresponding phis
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
244 for (PhiNode phi : newPhis) {
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 for (int i = 0; i < phi.valueCount(); i++) {
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 ValueNode v = phi.valueAt(i);
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 if (loopBegin.isPhiAtMerge(v)) {
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
248 PhiNode newV = peel.getDuplicatedNode((ValuePhiNode) v);
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
249 if (newV != 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
250 phi.setValueAt(i, newV);
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
251 }
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
252 }
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
253 }
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
254 }
16350
6055f84e41d7 LoopFragmentInside: make sure no dead phi are left after phis have been rewritten
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16059
diff changeset
255
6055f84e41d7 LoopFragmentInside: make sure no dead phi are left after phis have been rewritten
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16059
diff changeset
256 for (PhiNode deadPhi : loopBegin.phis().filter(n -> n.usages().isEmpty()).snapshot()) {
6055f84e41d7 LoopFragmentInside: make sure no dead phi are left after phis have been rewritten
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16059
diff changeset
257 if (deadPhi.isAlive()) {
6055f84e41d7 LoopFragmentInside: make sure no dead phi are left after phis have been rewritten
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16059
diff changeset
258 GraphUtil.killWithUnusedFloatingInputs(deadPhi);
6055f84e41d7 LoopFragmentInside: make sure no dead phi are left after phis have been rewritten
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16059
diff changeset
259 }
6055f84e41d7 LoopFragmentInside: make sure no dead phi are left after phis have been rewritten
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16059
diff changeset
260 }
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
261 }
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
262
16351
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
263 private static void markStateNodes(StateSplit stateSplit, NodeBitMap marks) {
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
264 FrameState exitState = stateSplit.stateAfter();
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
265 if (exitState != null) {
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
266 exitState.applyToVirtual(v -> marks.markAndGrow(v));
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
267 }
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
268 }
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
269
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
270 /**
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
271 * Gets the corresponding value in this fragment.
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
272 *
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
273 * @param b original 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
274 * @return corresponding value in the peel
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
275 */
15143
c68064651847 Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14978
diff changeset
276 @Override
c68064651847 Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14978
diff changeset
277 protected ValueNode prim(ValueNode b) {
5741
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
278 assert isDuplicate();
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
279 LoopBeginNode loopBegin = original().loop().loopBegin();
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
280 if (loopBegin.isPhiAtMerge(b)) {
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
281 PhiNode phi = (PhiNode) b;
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
282 return phi.valueAt(loopBegin.forwardEnd());
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
283 } else if (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
284 ValueNode v = getDuplicatedNode(b);
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
285 if (v == 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
286 return b;
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
287 }
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
288 return v;
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
289 } 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
290 return b;
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
291 }
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
292 }
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
293
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
294 private BeginNode mergeEnds() {
5741
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
295 assert isDuplicate();
9434
50f02c7d1cec Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9234
diff changeset
296 List<AbstractEndNode> endsToMerge = new LinkedList<>();
50f02c7d1cec Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9234
diff changeset
297 Map<AbstractEndNode, LoopEndNode> reverseEnds = new HashMap<>(); // map peel's exit to the
50f02c7d1cec Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9234
diff changeset
298 // corresponding loop exits
5741
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5717
diff changeset
299 LoopBeginNode loopBegin = original().loop().loopBegin();
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
300 for (LoopEndNode le : loopBegin.loopEnds()) {
9434
50f02c7d1cec Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9234
diff changeset
301 AbstractEndNode duplicate = getDuplicatedNode(le);
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
302 if (duplicate != 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
303 endsToMerge.add(duplicate);
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 reverseEnds.put(duplicate, le);
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
305 }
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
306 }
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
307 mergedInitializers = Node.newIdentityMap();
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
308 BeginNode newExit;
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 StructuredGraph graph = 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
310 if (endsToMerge.size() == 1) {
9434
50f02c7d1cec Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9234
diff changeset
311 AbstractEndNode end = endsToMerge.get(0);
11532
6a1b7d28f2d4 replace usages().count() == 0 with usages().isEmpty()
Doug Simon <doug.simon@oracle.com>
parents: 9602
diff changeset
312 assert end.usages().isEmpty();
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16351
diff changeset
313 newExit = graph.add(BeginNode.create());
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
314 end.replaceAtPredecessor(newExit);
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
315 end.safeDelete();
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
316 } 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
317 assert endsToMerge.size() > 1;
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16351
diff changeset
318 MergeNode newExitMerge = graph.add(MergeNode.create());
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
319 newExit = newExitMerge;
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
320 FrameState state = loopBegin.stateAfter();
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
321 FrameState duplicateState = null;
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
322 if (state != null) {
5713
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
323 duplicateState = state.duplicateWithVirtualState();
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
324 newExitMerge.setStateAfter(duplicateState);
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
325 }
9434
50f02c7d1cec Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9234
diff changeset
326 for (AbstractEndNode end : endsToMerge) {
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
327 newExitMerge.addForwardEnd(end);
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
328 }
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
329
5671
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
330 for (final PhiNode phi : loopBegin.phis().snapshot()) {
15144
76695509b2fd Avoid precessing unused phis during peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
331 if (phi.usages().isEmpty()) {
76695509b2fd Avoid precessing unused phis during peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
332 continue;
76695509b2fd Avoid precessing unused phis during peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
333 }
13152
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 11669
diff changeset
334 final PhiNode firstPhi = patchPhi(graph, phi, newExitMerge);
9434
50f02c7d1cec Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9234
diff changeset
335 for (AbstractEndNode end : newExitMerge.forwardEnds()) {
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
336 LoopEndNode loopEnd = reverseEnds.get(end);
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
337 ValueNode prim = prim(phi.valueAt(loopEnd));
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
338 assert prim != 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
339 firstPhi.addInput(prim);
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
340 }
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
341 ValueNode initializer = firstPhi;
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
342 if (duplicateState != null) {
5671
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
343 // fix the merge's state after
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
344 duplicateState.applyToNonVirtual(new NodeClosure<ValueNode>() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
345
5671
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
346 @Override
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
347 public void apply(Node from, ValueNode node) {
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
348 if (node == phi) {
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
349 from.replaceFirstInput(phi, firstPhi);
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
350 }
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
351 }
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
352 });
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
353 }
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
354 mergedInitializers.put((ValuePhiNode) phi, initializer);
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
355 }
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
356 }
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
357 return newExit;
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
358 }
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
359 }