annotate graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java @ 18154:448be95baef8

Add Backend.newFrameMapBuilder().
author Josef Eisl <josef.eisl@jku.at>
date Wed, 22 Oct 2014 17:51:08 +0200
parents 06c15e88d383
children 1518c3296cc8
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
15551
33cedbce5b23 added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents: 15341
diff changeset
25 import static com.oracle.graal.graph.util.CollectionsAccess.*;
33cedbce5b23 added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents: 15341
diff changeset
26
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
27 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
28
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15145
diff changeset
29 import com.oracle.graal.compiler.common.*;
15551
33cedbce5b23 added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents: 15341
diff changeset
30 import com.oracle.graal.graph.Graph.DuplicationReplacement;
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
31 import com.oracle.graal.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
32 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
33 import com.oracle.graal.nodes.*;
5671
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
34 import com.oracle.graal.nodes.VirtualState.NodeClosure;
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
35 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
36
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
37 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
38
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
39 /**
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
40 * 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
41 * 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
42 * 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
43 * 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
44 * 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
45 */
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
46 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
47 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
48
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
49 @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
50 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
51 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
52 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
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 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
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 };
5d0d72b37f88 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
5d0d72b37f88 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 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
59 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
60 }
5d0d72b37f88 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
5d0d72b37f88 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 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
63 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
64 }
5d0d72b37f88 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
5d0d72b37f88 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 @Override
16059
bab1a955411e Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16038
diff changeset
67 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
68 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
69 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
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 @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
73 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
74 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
75 }
5d0d72b37f88 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
5498
eb0d4946a1ea Fix compiler warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5489
diff changeset
77 @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
78 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
79 // 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
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
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
82 @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
83 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
84 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
85 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
86 }
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
87
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 @Override
16059
bab1a955411e Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16038
diff changeset
89 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
90 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
91
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
92 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
93
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
94 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
95
16059
bab1a955411e Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16038
diff changeset
96 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
97
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
98 original().patchPeeling(this);
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
99
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
100 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
101 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
102 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
103 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
104
5d0d72b37f88 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 @Override
15956
edc33e8715d5 NodeWorkList refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15955
diff changeset
106 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
107 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
108 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
109 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
110 nodes = whole.nodes.copy();
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
111 // remove the phis
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
112 LoopBeginNode loopBegin = loop().loopBegin();
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
113 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
114 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
115 }
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(loopBegin);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
117 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
118 clearStateNodes(exit);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
119 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
120 nodes.clear(proxy);
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
121 }
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
122 }
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
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 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
125 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
126
16351
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
127 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
128 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
129 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
130 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
131 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
132 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
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 }
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
136 }
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
137
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
138 public NodeIterable<LoopExitNode> exits() {
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
139 return loop().loopBegin().loopExits();
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
140 }
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
141
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
142 @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
143 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
144 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
145 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
146 return new DuplicationReplacement() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
147
11669
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
148 private HashMap<Node, Node> seenNode = new HashMap<>();
a625d254e137 Avoid allocation of replacement hashmap in addDuplicates and also in InliningUtil.inline.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
149
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 @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
151 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
152 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
153 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
154 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
155 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
156 }
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
157 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
158 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
159 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
160 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
161 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
162 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
163 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
164 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
165 }
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
166 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
167 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
168 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
169 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
170 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
171 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
172 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
173 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
174 }
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
175 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
176 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
177 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
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 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
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 }
5d0d72b37f88 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
5d0d72b37f88 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 @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
185 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
186 // 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
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
13152
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 11669
diff changeset
189 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
190 PhiNode ret;
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
191 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
192 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
193 } 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
194 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
195 } 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
196 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
197 } else {
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
198 throw GraalInternalError.shouldNotReachHere();
13152
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 return graph.addWithoutUnique(ret);
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 11669
diff changeset
201 }
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 11669
diff changeset
202
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
203 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
204 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
205 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
206 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
207
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
208 NodeBitMap usagesToPatch = nodes.copy();
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
209 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
210 markStateNodes(exit, usagesToPatch);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
211 for (ProxyNode proxy : exit.proxies()) {
15955
3f48e9a1016c NodeBitMap refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15551
diff changeset
212 usagesToPatch.markAndGrow(proxy);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
213 }
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
214 }
16351
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
215 markStateNodes(loopBegin, usagesToPatch);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
216
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
217 for (PhiNode phi : loopBegin.phis().snapshot()) {
15144
76695509b2fd Avoid precessing unused phis during peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
218 if (phi.usages().isEmpty()) {
76695509b2fd Avoid precessing unused phis during peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
219 continue;
76695509b2fd Avoid precessing unused phis during peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
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 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
222 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
223 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
224 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
225 } 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
226 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
227 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
228 // 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
229 // still be valid)
13152
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 11669
diff changeset
230 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
231 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
232 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
233 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
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 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
236 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
237 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
238 // 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
239 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
240 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
241 }
5d0d72b37f88 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 }
5d0d72b37f88 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 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
244 // 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
245 // 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
246 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
247 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
248 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
249 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
250 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
251 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
252 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
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 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
255 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
256 }
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
257
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 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
259 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
260 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
261 }
6055f84e41d7 LoopFragmentInside: make sure no dead phi are left after phis have been rewritten
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16059
diff changeset
262 }
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
263 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
264
16351
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
265 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
266 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
267 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
268 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
269 }
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
270 }
3e341c30e5c0 No need to duplicate the loop begin's state for LoopFragmentInside
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16350
diff changeset
271
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
272 /**
5d0d72b37f88 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 * 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
274 *
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
275 * @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
276 * @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
277 */
15143
c68064651847 Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14978
diff changeset
278 @Override
c68064651847 Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14978
diff changeset
279 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
280 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
281 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
282 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
283 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
284 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
285 } 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
286 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
287 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
288 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
289 }
5d0d72b37f88 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 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
291 } 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
292 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
293 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
294 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
295
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
296 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
297 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
298 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
299 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
300 // 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
301 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
302 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
303 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
304 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
305 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
306 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
307 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
308 }
15551
33cedbce5b23 added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents: 15341
diff changeset
309 mergedInitializers = newNodeIdentityMap();
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15144
diff changeset
310 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
311 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
312 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
313 AbstractEndNode end = endsToMerge.get(0);
11532
6a1b7d28f2d4 replace usages().count() == 0 with usages().isEmpty()
Doug Simon <doug.simon@oracle.com>
parents: 9602
diff changeset
314 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
315 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
316 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
317 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
318 } 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
319 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
320 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
321 newExit = newExitMerge;
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
322 FrameState state = loopBegin.stateAfter();
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
323 FrameState duplicateState = null;
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
324 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
325 duplicateState = state.duplicateWithVirtualState();
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
326 newExitMerge.setStateAfter(duplicateState);
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
327 }
9434
50f02c7d1cec Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9234
diff changeset
328 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
329 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
330 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
331
5671
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
332 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
333 if (phi.usages().isEmpty()) {
76695509b2fd Avoid precessing unused phis during peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
334 continue;
76695509b2fd Avoid precessing unused phis during peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
335 }
13152
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 11669
diff changeset
336 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
337 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
338 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
339 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
340 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
341 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
342 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
343 ValueNode initializer = firstPhi;
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
344 if (duplicateState != null) {
5671
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
345 // fix the merge's state after
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
346 duplicateState.applyToNonVirtual(new NodeClosure<ValueNode>() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6545
diff changeset
347
5671
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
348 @Override
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
349 public void apply(Node from, ValueNode node) {
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
350 if (node == phi) {
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
351 from.replaceFirstInput(phi, firstPhi);
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
352 }
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
353 }
a65b2a11bf34 Fix for peeling and VirtualStateNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5639
diff changeset
354 });
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
355 }
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
356 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
357 }
5d0d72b37f88 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 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
360 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
361 }