Mercurial > hg > truffle
annotate graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java @ 21543:93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 25 May 2015 23:30:34 +0200 |
parents | a0ae5a2ac5cf |
children | b1530a6cce8c |
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 /* |
21452
a0ae5a2ac5cf
Support detection of long induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
21264
diff
changeset
|
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
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
|
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 |
19192
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
25 import static com.oracle.graal.graph.Node.*; |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
26 |
5732
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
27 import java.util.*; |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
28 |
15200
97eed257999b
Move Condition to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
29 import com.oracle.graal.compiler.common.calc.*; |
15192
644dfe49c0f4
Move packages com.oracle.graal.cfg to com.oracle.graal.compiler.common.cfg.
Josef Eisl <josef.eisl@jku.at>
parents:
15157
diff
changeset
|
30 import com.oracle.graal.compiler.common.cfg.*; |
19192
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
31 import com.oracle.graal.compiler.common.type.*; |
5675
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
32 import com.oracle.graal.debug.*; |
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
|
33 import com.oracle.graal.graph.*; |
5675
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
34 import com.oracle.graal.graph.iterators.*; |
12761
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
35 import com.oracle.graal.loop.InductionVariable.Direction; |
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 import com.oracle.graal.nodes.*; |
5675
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
37 import com.oracle.graal.nodes.calc.*; |
6529
2e96dc4eb8e2
renamed package: com.oracle.graal.lir.cfg -> com.oracle.graal.nodes.cfg
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
38 import com.oracle.graal.nodes.cfg.*; |
12761
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
39 import com.oracle.graal.nodes.extended.*; |
16352
00460aab5c96
Make sure LoopEx.reassociateInvariants doesn't leave dead nodes behind
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16217
diff
changeset
|
40 import com.oracle.graal.nodes.util.*; |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21452
diff
changeset
|
41 import com.oracle.jvmci.common.*; |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
42 |
5d0d72b37f88
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 public class LoopEx { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6537
diff
changeset
|
44 |
16191
3e3578bc8f9b
rename: lirLoop* -> loop*
Doug Simon <doug.simon@oracle.com>
parents:
15534
diff
changeset
|
45 private final Loop<Block> 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
|
46 private LoopFragmentInside inside; |
5d0d72b37f88
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 private LoopFragmentWhole whole; |
21095
9212e6b75c07
Small clean-up in LoopEx
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
20069
diff
changeset
|
48 private CountedLoopInfo counted; |
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 private LoopsData data; |
19192
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
50 private Map<Node, InductionVariable> ivs; |
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
|
51 |
16191
3e3578bc8f9b
rename: lirLoop* -> loop*
Doug Simon <doug.simon@oracle.com>
parents:
15534
diff
changeset
|
52 LoopEx(Loop<Block> loop, LoopsData data) { |
3e3578bc8f9b
rename: lirLoop* -> loop*
Doug Simon <doug.simon@oracle.com>
parents:
15534
diff
changeset
|
53 this.loop = 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
|
54 this.data = data; |
5d0d72b37f88
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 |
16191
3e3578bc8f9b
rename: lirLoop* -> loop*
Doug Simon <doug.simon@oracle.com>
parents:
15534
diff
changeset
|
57 public Loop<Block> loop() { |
3e3578bc8f9b
rename: lirLoop* -> loop*
Doug Simon <doug.simon@oracle.com>
parents:
15534
diff
changeset
|
58 return 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
|
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 |
5d0d72b37f88
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 public LoopFragmentInside inside() { |
5d0d72b37f88
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 if (inside == 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
|
63 inside = 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
|
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 return inside; |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
66 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
67 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
68 public LoopFragmentWhole 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
|
69 if (whole == 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
|
70 whole = new LoopFragmentWhole(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
|
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 return 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
|
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 |
12750
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
75 public void invalidateFragments() { |
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
76 inside = null; |
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
77 whole = null; |
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
78 } |
c61d1f1bbee0
Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents:
12655
diff
changeset
|
79 |
5498
eb0d4946a1ea
Fix compiler warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5489
diff
changeset
|
80 @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
|
81 public LoopFragmentInsideFrom insideFrom(FixedNode point) { |
5d0d72b37f88
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 // 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
|
83 return 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
|
84 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
85 |
5498
eb0d4946a1ea
Fix compiler warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5489
diff
changeset
|
86 @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
|
87 public LoopFragmentInsideBefore insideBefore(FixedNode point) { |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
88 // 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
|
89 return 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
|
90 } |
5d0d72b37f88
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 |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5520
diff
changeset
|
92 public boolean isOutsideLoop(Node n) { |
13327
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12761
diff
changeset
|
93 return !whole().contains(n); |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
94 } |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
95 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
96 public LoopBeginNode loopBegin() { |
16191
3e3578bc8f9b
rename: lirLoop* -> loop*
Doug Simon <doug.simon@oracle.com>
parents:
15534
diff
changeset
|
97 return (LoopBeginNode) loop().getHeader().getBeginNode(); |
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
|
98 } |
5d0d72b37f88
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 |
5d0d72b37f88
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 public FixedNode predecessor() { |
5d0d72b37f88
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 return (FixedNode) loopBegin().forwardEnd().predecessor(); |
5d0d72b37f88
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 |
5d0d72b37f88
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 public FixedNode 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
|
105 return 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
|
106 } |
5d0d72b37f88
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 |
5d0d72b37f88
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 public boolean isCounted() { |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5520
diff
changeset
|
109 return counted != null; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5520
diff
changeset
|
110 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5520
diff
changeset
|
111 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5520
diff
changeset
|
112 public CountedLoopInfo counted() { |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5520
diff
changeset
|
113 return counted; |
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 } |
5d0d72b37f88
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 |
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
116 public LoopEx parent() { |
16191
3e3578bc8f9b
rename: lirLoop* -> loop*
Doug Simon <doug.simon@oracle.com>
parents:
15534
diff
changeset
|
117 if (loop.getParent() == null) { |
5489
5d0d72b37f88
Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
118 return 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
|
119 } |
16191
3e3578bc8f9b
rename: lirLoop* -> loop*
Doug Simon <doug.simon@oracle.com>
parents:
15534
diff
changeset
|
120 return data.loop(loop.getParent()); |
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 |
5d0d72b37f88
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 public int size() { |
5d0d72b37f88
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 whole().nodes().count(); |
5d0d72b37f88
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 } |
5519
cedae73d9c2a
Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5489
diff
changeset
|
126 |
cedae73d9c2a
Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5489
diff
changeset
|
127 @Override |
cedae73d9c2a
Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5489
diff
changeset
|
128 public String toString() { |
16191
3e3578bc8f9b
rename: lirLoop* -> loop*
Doug Simon <doug.simon@oracle.com>
parents:
15534
diff
changeset
|
129 return (isCounted() ? "CountedLoop [" + counted() + "] " : "Loop ") + "(depth=" + loop().getDepth() + ") " + loopBegin(); |
5675
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
130 } |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
131 |
15136
140bd4b4e3c6
Make NodePredicate an interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15108
diff
changeset
|
132 private class InvariantPredicate implements NodePredicate { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6537
diff
changeset
|
133 |
5675
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
134 @Override |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
135 public boolean apply(Node n) { |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
136 return isOutsideLoop(n); |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
137 } |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
138 } |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
139 |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
140 public void reassociateInvariants() { |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
141 InvariantPredicate invariant = new InvariantPredicate(); |
9602
19c5a07c7843
Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9446
diff
changeset
|
142 StructuredGraph graph = loopBegin().graph(); |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17418
diff
changeset
|
143 for (BinaryArithmeticNode<?> binary : whole().nodes().filter(BinaryArithmeticNode.class)) { |
17418
393fe459eadc
Don't cache op field in arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
144 if (!binary.isAssociative()) { |
5675
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
145 continue; |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
146 } |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17418
diff
changeset
|
147 BinaryArithmeticNode<?> result = BinaryArithmeticNode.reassociate(binary, invariant, binary.getX(), binary.getY()); |
5675
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
148 if (result != binary) { |
6537
14c952ec53a3
Fix NullPointerException when disabling Debug
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6529
diff
changeset
|
149 if (Debug.isLogEnabled()) { |
16480
10c12d09a8d2
moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16352
diff
changeset
|
150 Debug.log("%s : Reassociated %s into %s", graph.method().format("%H::%n"), binary, result); |
6537
14c952ec53a3
Fix NullPointerException when disabling Debug
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6529
diff
changeset
|
151 } |
16217
561070049e73
implement Canonicalizable.Binary in the BinaryNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
152 if (!result.isAlive()) { |
561070049e73
implement Canonicalizable.Binary in the BinaryNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
153 assert !result.isDeleted(); |
561070049e73
implement Canonicalizable.Binary in the BinaryNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
154 result = graph.addOrUniqueWithInputs(result); |
561070049e73
implement Canonicalizable.Binary in the BinaryNode hierarchy
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16207
diff
changeset
|
155 } |
16352
00460aab5c96
Make sure LoopEx.reassociateInvariants doesn't leave dead nodes behind
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16217
diff
changeset
|
156 binary.replaceAtUsages(result); |
00460aab5c96
Make sure LoopEx.reassociateInvariants doesn't leave dead nodes behind
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16217
diff
changeset
|
157 GraphUtil.killWithUnusedFloatingInputs(binary); |
5675
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
158 } |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
159 } |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
160 } |
776366f3a41a
A bit of work on counted loops
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
161 |
12761
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
162 public boolean detectCounted() { |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
163 LoopBeginNode loopBegin = loopBegin(); |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
164 FixedNode next = loopBegin.next(); |
21264
3db917232621
Counted loop detection should ignore InfopointNodes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21095
diff
changeset
|
165 while (next instanceof FixedGuardNode || next instanceof ValueAnchorNode || next instanceof InfopointNode) { |
12761
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
166 next = ((FixedWithNextNode) next).next(); |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
167 } |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
168 if (next instanceof IfNode) { |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
169 IfNode ifNode = (IfNode) next; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
170 boolean negated = false; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
171 if (!loopBegin.isLoopExit(ifNode.falseSuccessor())) { |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
172 if (!loopBegin.isLoopExit(ifNode.trueSuccessor())) { |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
173 return false; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
174 } |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
175 negated = true; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
176 } |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
177 LogicNode ifTest = ifNode.condition(); |
19631
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
178 if (!(ifTest instanceof IntegerLessThanNode) && !(ifTest instanceof IntegerEqualsNode)) { |
16601
cd25e42d9b22
rename IntegerBelowThanNode to IntegerBelowNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16480
diff
changeset
|
179 if (ifTest instanceof IntegerBelowNode) { |
12761
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
180 Debug.log("Ignored potential Counted loop at %s with |<|", loopBegin); |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
181 } |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
182 return false; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
183 } |
19631
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
184 CompareNode lessThan = (CompareNode) ifTest; |
12761
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
185 Condition condition = null; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
186 InductionVariable iv = null; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
187 ValueNode limit = null; |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16194
diff
changeset
|
188 if (isOutsideLoop(lessThan.getX())) { |
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16194
diff
changeset
|
189 iv = getInductionVariables().get(lessThan.getY()); |
12761
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
190 if (iv != null) { |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
191 condition = lessThan.condition().mirror(); |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16194
diff
changeset
|
192 limit = lessThan.getX(); |
12761
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
193 } |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16194
diff
changeset
|
194 } else if (isOutsideLoop(lessThan.getY())) { |
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16194
diff
changeset
|
195 iv = getInductionVariables().get(lessThan.getX()); |
12761
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
196 if (iv != null) { |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
197 condition = lessThan.condition(); |
16207
df6f2365b153
rename of x() to getX(), y() to getY() and object() to getValue()
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16194
diff
changeset
|
198 limit = lessThan.getY(); |
12761
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
199 } |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
200 } |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
201 if (condition == null) { |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
202 return false; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
203 } |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
204 if (negated) { |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
205 condition = condition.negate(); |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
206 } |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
207 boolean oneOff = false; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
208 switch (condition) { |
19631
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
209 case EQ: |
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
210 return false; |
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
211 case NE: { |
21095
9212e6b75c07
Small clean-up in LoopEx
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
20069
diff
changeset
|
212 if (!iv.isConstantStride() || Math.abs(iv.constantStride()) != 1) { |
9212e6b75c07
Small clean-up in LoopEx
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
20069
diff
changeset
|
213 return false; |
9212e6b75c07
Small clean-up in LoopEx
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
20069
diff
changeset
|
214 } |
19631
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
215 IntegerStamp initStamp = (IntegerStamp) iv.initNode().stamp(); |
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
216 IntegerStamp limitStamp = (IntegerStamp) limit.stamp(); |
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
217 if (iv.direction() == Direction.Up) { |
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
218 if (initStamp.upperBound() > limitStamp.lowerBound()) { |
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
219 return false; |
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
220 } |
19918
c278c8c727aa
More checks that InductionVariable.direction is valid
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19635
diff
changeset
|
221 } else if (iv.direction() == Direction.Down) { |
19631
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
222 if (initStamp.lowerBound() < limitStamp.upperBound()) { |
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
223 return false; |
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
224 } |
19918
c278c8c727aa
More checks that InductionVariable.direction is valid
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19635
diff
changeset
|
225 } else { |
c278c8c727aa
More checks that InductionVariable.direction is valid
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19635
diff
changeset
|
226 return false; |
19631
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
227 } |
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
228 oneOff = true; |
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
229 break; |
312bf1b3f410
Support == as a loop exit condition of counted loops.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19263
diff
changeset
|
230 } |
12761
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
231 case LE: |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
232 oneOff = true; // fall through |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
233 case LT: |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
234 if (iv.direction() != Direction.Up) { |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
235 return false; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
236 } |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
237 break; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
238 case GE: |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
239 oneOff = true; // fall through |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
240 case GT: |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
241 if (iv.direction() != Direction.Down) { |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
242 return false; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
243 } |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
244 break; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
245 default: |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21452
diff
changeset
|
246 throw JVMCIError.shouldNotReachHere(); |
12761
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
247 } |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
248 counted = new CountedLoopInfo(this, iv, limit, oneOff, negated ? ifNode.falseSuccessor() : ifNode.trueSuccessor()); |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
249 return true; |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
250 } |
8b82bdad798a
Make it possible to run counted loop detection on a single loop.
Roland Schatz <roland.schatz@oracle.com>
parents:
12750
diff
changeset
|
251 return false; |
5519
cedae73d9c2a
Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5489
diff
changeset
|
252 } |
5732
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
253 |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
254 public LoopsData loopsData() { |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
255 return data; |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
256 } |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
257 |
19263
b42653236a83
Transform LoopEx.nodesInLoopFrom into LoopEd nodesInLoopBranch
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
19192
diff
changeset
|
258 public NodeBitMap nodesInLoopBranch(AbstractBeginNode branch) { |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
17419
diff
changeset
|
259 Collection<AbstractBeginNode> blocks = new LinkedList<>(); |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15136
diff
changeset
|
260 Collection<LoopExitNode> exits = new LinkedList<>(); |
5732
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
261 Queue<Block> work = new LinkedList<>(); |
20069
2dbfa1ed5efa
Reduce usages of fixed node probability cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19919
diff
changeset
|
262 ControlFlowGraph cfg = loopsData().getCFG(); |
19263
b42653236a83
Transform LoopEx.nodesInLoopFrom into LoopEd nodesInLoopBranch
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
19192
diff
changeset
|
263 work.add(cfg.blockFor(branch)); |
5732
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
264 while (!work.isEmpty()) { |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
265 Block b = work.remove(); |
16191
3e3578bc8f9b
rename: lirLoop* -> loop*
Doug Simon <doug.simon@oracle.com>
parents:
15534
diff
changeset
|
266 if (loop().getExits().contains(b)) { |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15136
diff
changeset
|
267 exits.add((LoopExitNode) b.getBeginNode()); |
19263
b42653236a83
Transform LoopEx.nodesInLoopFrom into LoopEd nodesInLoopBranch
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
19192
diff
changeset
|
268 } else { |
5732
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
269 blocks.add(b.getBeginNode()); |
19919
df0608c34899
Don't walk out of loop when estimating unswitch benefits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19918
diff
changeset
|
270 for (Block d : b.getDominated()) { |
df0608c34899
Don't walk out of loop when estimating unswitch benefits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19918
diff
changeset
|
271 if (loop.getBlocks().contains(d)) { |
df0608c34899
Don't walk out of loop when estimating unswitch benefits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19918
diff
changeset
|
272 work.add(d); |
df0608c34899
Don't walk out of loop when estimating unswitch benefits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19918
diff
changeset
|
273 } |
df0608c34899
Don't walk out of loop when estimating unswitch benefits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19918
diff
changeset
|
274 } |
5732
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
275 } |
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
276 } |
19263
b42653236a83
Transform LoopEx.nodesInLoopFrom into LoopEd nodesInLoopBranch
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
19192
diff
changeset
|
277 return LoopFragment.computeNodes(branch.graph(), blocks, exits); |
5732
e1d5c642d022
Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5719
diff
changeset
|
278 } |
9446
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9436
diff
changeset
|
279 |
19192
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
280 public Map<Node, InductionVariable> getInductionVariables() { |
9446
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9436
diff
changeset
|
281 if (ivs == null) { |
19192
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
282 ivs = findInductionVariables(this); |
9446
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9436
diff
changeset
|
283 } |
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9436
diff
changeset
|
284 return ivs; |
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9436
diff
changeset
|
285 } |
16194
7fb828b4c32b
made LoopsData clients clean up dead nodes created during loop analysis
Doug Simon <doug.simon@oracle.com>
parents:
16191
diff
changeset
|
286 |
7fb828b4c32b
made LoopsData clients clean up dead nodes created during loop analysis
Doug Simon <doug.simon@oracle.com>
parents:
16191
diff
changeset
|
287 /** |
19192
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
288 * Collect all the basic induction variables for the loop and the find any induction variables |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
289 * which are derived from the basic ones. |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
290 * |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
291 * @param loop |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
292 * @return a map from node to induction variable |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
293 */ |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
294 private static Map<Node, InductionVariable> findInductionVariables(LoopEx loop) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
295 Map<Node, InductionVariable> ivs = newIdentityMap(); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
296 |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
297 Queue<InductionVariable> scanQueue = new LinkedList<>(); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
298 LoopBeginNode loopBegin = loop.loopBegin(); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
299 AbstractEndNode forwardEnd = loopBegin.forwardEnd(); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
300 for (PhiNode phi : loopBegin.phis().filter(ValuePhiNode.class)) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
301 ValueNode backValue = phi.singleBackValue(); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
302 if (backValue == PhiNode.MULTIPLE_VALUES) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
303 continue; |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
304 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
305 ValueNode stride = addSub(loop, backValue, phi); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
306 if (stride != null) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
307 BasicInductionVariable biv = new BasicInductionVariable(loop, (ValuePhiNode) phi, phi.valueAt(forwardEnd), stride, (BinaryArithmeticNode<?>) backValue); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
308 ivs.put(phi, biv); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
309 scanQueue.add(biv); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
310 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
311 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
312 |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
313 while (!scanQueue.isEmpty()) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
314 InductionVariable baseIv = scanQueue.remove(); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
315 ValueNode baseIvNode = baseIv.valueNode(); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
316 for (ValueNode op : baseIvNode.usages().filter(ValueNode.class)) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
317 if (loop.isOutsideLoop(op)) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
318 continue; |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
319 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
320 if (op.usages().count() == 1 && op.usages().first() == baseIvNode) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
321 /* |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
322 * This is just the base induction variable increment with no other uses so |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
323 * don't bother reporting it. |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
324 */ |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
325 continue; |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
326 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
327 InductionVariable iv = null; |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
328 ValueNode offset = addSub(loop, op, baseIvNode); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
329 ValueNode scale; |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
330 if (offset != null) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
331 iv = new DerivedOffsetInductionVariable(loop, baseIv, offset, (BinaryArithmeticNode<?>) op); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
332 } else if (op instanceof NegateNode) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
333 iv = new DerivedScaledInductionVariable(loop, baseIv, (NegateNode) op); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
334 } else if ((scale = mul(loop, op, baseIvNode)) != null) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
335 iv = new DerivedScaledInductionVariable(loop, baseIv, scale, op); |
21452
a0ae5a2ac5cf
Support detection of long induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
21264
diff
changeset
|
336 } else { |
a0ae5a2ac5cf
Support detection of long induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
21264
diff
changeset
|
337 boolean isValidConvert = op instanceof PiNode || op instanceof SignExtendNode; |
a0ae5a2ac5cf
Support detection of long induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
21264
diff
changeset
|
338 if (!isValidConvert && op instanceof ZeroExtendNode) { |
a0ae5a2ac5cf
Support detection of long induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
21264
diff
changeset
|
339 IntegerStamp inputStamp = (IntegerStamp) ((ZeroExtendNode) op).getValue().stamp(); |
a0ae5a2ac5cf
Support detection of long induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
21264
diff
changeset
|
340 isValidConvert = inputStamp.isPositive(); |
a0ae5a2ac5cf
Support detection of long induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
21264
diff
changeset
|
341 } |
a0ae5a2ac5cf
Support detection of long induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
21264
diff
changeset
|
342 |
a0ae5a2ac5cf
Support detection of long induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
21264
diff
changeset
|
343 if (isValidConvert) { |
a0ae5a2ac5cf
Support detection of long induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
21264
diff
changeset
|
344 iv = new DerivedConvertedInductionVariable(loop, baseIv, op.stamp(), op); |
a0ae5a2ac5cf
Support detection of long induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
21264
diff
changeset
|
345 } |
19192
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
346 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
347 |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
348 if (iv != null) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
349 ivs.put(op, iv); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
350 scanQueue.offer(iv); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
351 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
352 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
353 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
354 return Collections.unmodifiableMap(ivs); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
355 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
356 |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
357 private static ValueNode addSub(LoopEx loop, ValueNode op, ValueNode base) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
358 if (op.stamp() instanceof IntegerStamp && (op instanceof AddNode || op instanceof SubNode)) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
359 BinaryArithmeticNode<?> aritOp = (BinaryArithmeticNode<?>) op; |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
360 if (aritOp.getX() == base && loop.isOutsideLoop(aritOp.getY())) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
361 return aritOp.getY(); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
362 } else if (aritOp.getY() == base && loop.isOutsideLoop(aritOp.getX())) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
363 return aritOp.getX(); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
364 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
365 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
366 return null; |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
367 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
368 |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
369 private static ValueNode mul(LoopEx loop, ValueNode op, ValueNode base) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
370 if (op instanceof MulNode) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
371 MulNode mul = (MulNode) op; |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
372 if (mul.getX() == base && loop.isOutsideLoop(mul.getY())) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
373 return mul.getY(); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
374 } else if (mul.getY() == base && loop.isOutsideLoop(mul.getX())) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
375 return mul.getX(); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
376 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
377 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
378 if (op instanceof LeftShiftNode) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
379 LeftShiftNode shift = (LeftShiftNode) op; |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
380 if (shift.getX() == base && shift.getY().isConstant()) { |
21452
a0ae5a2ac5cf
Support detection of long induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
21264
diff
changeset
|
381 return ConstantNode.forIntegerStamp(base.stamp(), 1 << shift.getY().asJavaConstant().asInt(), base.graph()); |
19192
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
382 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
383 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
384 return null; |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
385 } |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
386 |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
387 /** |
16194
7fb828b4c32b
made LoopsData clients clean up dead nodes created during loop analysis
Doug Simon <doug.simon@oracle.com>
parents:
16191
diff
changeset
|
388 * Deletes any nodes created within the scope of this object that have no usages. |
7fb828b4c32b
made LoopsData clients clean up dead nodes created during loop analysis
Doug Simon <doug.simon@oracle.com>
parents:
16191
diff
changeset
|
389 */ |
7fb828b4c32b
made LoopsData clients clean up dead nodes created during loop analysis
Doug Simon <doug.simon@oracle.com>
parents:
16191
diff
changeset
|
390 public void deleteUnusedNodes() { |
7fb828b4c32b
made LoopsData clients clean up dead nodes created during loop analysis
Doug Simon <doug.simon@oracle.com>
parents:
16191
diff
changeset
|
391 if (ivs != null) { |
19192
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
392 for (InductionVariable iv : ivs.values()) { |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
393 iv.deleteUnusedNodes(); |
a7fb05f3d7e1
Move induction variable detection logic into LoopEx
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18993
diff
changeset
|
394 } |
16194
7fb828b4c32b
made LoopsData clients clean up dead nodes created during loop analysis
Doug Simon <doug.simon@oracle.com>
parents:
16191
diff
changeset
|
395 } |
7fb828b4c32b
made LoopsData clients clean up dead nodes created during loop analysis
Doug Simon <doug.simon@oracle.com>
parents:
16191
diff
changeset
|
396 } |
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
|
397 } |