Mercurial > hg > truffle
annotate graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java @ 19190:18c2fd3d7fc7
Cleanup InductionVariable declarations a bit
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Mon, 09 Feb 2015 15:52:17 -0800 |
parents | fe3a00661c32 |
children | ef52cebd4030 |
rev | line source |
---|---|
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
1 /* |
19190
18c2fd3d7fc7
Cleanup InductionVariable declarations a bit
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18953
diff
changeset
|
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
4 * |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
8 * |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
14 * |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
18 * |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
21 * questions. |
9f3250602d69
Preliminary counted loop detection
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; |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
24 |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
25 import com.oracle.graal.compiler.common.*; |
15198
2c0cfbf454b5
Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
26 import com.oracle.graal.compiler.common.type.*; |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
27 import com.oracle.graal.nodes.*; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
28 import com.oracle.graal.nodes.calc.*; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
29 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
30 public class BasicInductionVariable extends InductionVariable { |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
31 |
19190
18c2fd3d7fc7
Cleanup InductionVariable declarations a bit
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18953
diff
changeset
|
32 private final ValuePhiNode phi; |
18c2fd3d7fc7
Cleanup InductionVariable declarations a bit
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18953
diff
changeset
|
33 private final ValueNode init; |
18c2fd3d7fc7
Cleanup InductionVariable declarations a bit
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18953
diff
changeset
|
34 private final ValueNode rawStride; |
18c2fd3d7fc7
Cleanup InductionVariable declarations a bit
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18953
diff
changeset
|
35 private final BinaryArithmeticNode<?> op; |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
36 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
37 public BasicInductionVariable(LoopEx loop, ValuePhiNode phi, ValueNode init, ValueNode rawStride, BinaryArithmeticNode<?> op) { |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
38 super(loop); |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
39 this.phi = phi; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
40 this.init = init; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
41 this.rawStride = rawStride; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
42 this.op = op; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
43 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
44 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
45 @Override |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11263
diff
changeset
|
46 public StructuredGraph graph() { |
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11263
diff
changeset
|
47 return phi.graph(); |
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11263
diff
changeset
|
48 } |
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11263
diff
changeset
|
49 |
18953
fe3a00661c32
Add toString and some accessors to InductionVariable subclasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18845
diff
changeset
|
50 public BinaryArithmeticNode<?> getOp() { |
fe3a00661c32
Add toString and some accessors to InductionVariable subclasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18845
diff
changeset
|
51 return op; |
fe3a00661c32
Add toString and some accessors to InductionVariable subclasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18845
diff
changeset
|
52 } |
fe3a00661c32
Add toString and some accessors to InductionVariable subclasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18845
diff
changeset
|
53 |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11263
diff
changeset
|
54 @Override |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
55 public Direction direction() { |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
56 Stamp stamp = rawStride.stamp(); |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
57 if (stamp instanceof IntegerStamp) { |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
58 IntegerStamp integerStamp = (IntegerStamp) stamp; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
59 Direction dir = null; |
6299
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
60 if (integerStamp.isStrictlyPositive()) { |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
61 dir = Direction.Up; |
6299
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5610
diff
changeset
|
62 } else if (integerStamp.isStrictlyNegative()) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6523
diff
changeset
|
63 dir = Direction.Down; |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
64 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
65 if (dir != null) { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
16895
diff
changeset
|
66 if (op instanceof AddNode) { |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
67 return dir; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
68 } else { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
16895
diff
changeset
|
69 assert op instanceof SubNode; |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
70 return dir.opposite(); |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
71 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
72 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
73 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
74 return null; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
75 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
76 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
77 @Override |
14978
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14000
diff
changeset
|
78 public ValuePhiNode valueNode() { |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
79 return phi; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
80 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
81 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
82 @Override |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
83 public ValueNode initNode() { |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
84 return init; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
85 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
86 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
87 @Override |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
88 public ValueNode strideNode() { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
16895
diff
changeset
|
89 if (op instanceof AddNode) { |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
90 return rawStride; |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
91 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
16895
diff
changeset
|
92 if (op instanceof SubNode) { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
93 return graph().unique(new NegateNode(rawStride)); |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
94 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
95 throw GraalInternalError.shouldNotReachHere(); |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
96 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
97 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
98 @Override |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
99 public boolean isConstantInit() { |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
100 return init.isConstant(); |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
101 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
102 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
103 @Override |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
104 public boolean isConstantStride() { |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
105 return rawStride.isConstant(); |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
106 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
107 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
108 @Override |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
109 public long constantInit() { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17419
diff
changeset
|
110 return init.asJavaConstant().asLong(); |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
111 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
112 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
113 @Override |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
114 public long constantStride() { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
16895
diff
changeset
|
115 if (op instanceof AddNode) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17419
diff
changeset
|
116 return rawStride.asJavaConstant().asLong(); |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
117 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
16895
diff
changeset
|
118 if (op instanceof SubNode) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17419
diff
changeset
|
119 return -rawStride.asJavaConstant().asLong(); |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
120 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
121 throw GraalInternalError.shouldNotReachHere(); |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
122 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
123 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
124 @Override |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
12720
diff
changeset
|
125 public ValueNode extremumNode(boolean assumePositiveTripCount, Stamp stamp) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
12720
diff
changeset
|
126 Stamp fromStamp = phi.stamp(); |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11263
diff
changeset
|
127 StructuredGraph graph = graph(); |
9446
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7530
diff
changeset
|
128 ValueNode stride = strideNode(); |
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7530
diff
changeset
|
129 ValueNode initNode = this.initNode(); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
12720
diff
changeset
|
130 if (!fromStamp.isCompatible(stamp)) { |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
131 stride = IntegerConvertNode.convert(stride, stamp, graph()); |
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
132 initNode = IntegerConvertNode.convert(initNode, stamp, graph()); |
9446
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7530
diff
changeset
|
133 } |
12720
8898d449f95d
Fix wrong conversion in extremum and exit values of induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
12656
diff
changeset
|
134 ValueNode maxTripCount = loop.counted().maxTripCountNode(assumePositiveTripCount); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
12720
diff
changeset
|
135 if (!maxTripCount.stamp().isCompatible(stamp)) { |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
136 maxTripCount = IntegerConvertNode.convert(maxTripCount, stamp, graph()); |
12720
8898d449f95d
Fix wrong conversion in extremum and exit values of induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
12656
diff
changeset
|
137 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
16895
diff
changeset
|
138 return BinaryArithmeticNode.add(graph, BinaryArithmeticNode.mul(graph, stride, BinaryArithmeticNode.sub(graph, maxTripCount, ConstantNode.forIntegerStamp(stamp, 1, graph))), initNode); |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
139 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
140 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
141 @Override |
11263
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
142 public ValueNode exitValueNode() { |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
12720
diff
changeset
|
143 Stamp stamp = phi.stamp(); |
11263
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
144 ValueNode maxTripCount = loop.counted().maxTripCountNode(false); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
12720
diff
changeset
|
145 if (!maxTripCount.stamp().isCompatible(stamp)) { |
16248
c5b2a3c22318
refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
146 maxTripCount = IntegerConvertNode.convert(maxTripCount, stamp, graph()); |
12720
8898d449f95d
Fix wrong conversion in extremum and exit values of induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
12656
diff
changeset
|
147 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
16895
diff
changeset
|
148 return BinaryArithmeticNode.add(graph(), BinaryArithmeticNode.mul(graph(), strideNode(), maxTripCount), initNode()); |
11263
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
149 } |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
150 |
acf09b065eba
Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents:
9446
diff
changeset
|
151 @Override |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
152 public boolean isConstantExtremum() { |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
153 return isConstantInit() && isConstantStride() && loop.counted().isConstantMaxTripCount(); |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
154 } |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
155 |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
156 @Override |
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
157 public long constantExtremum() { |
9446
27733a62ba72
Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7530
diff
changeset
|
158 return constantStride() * (loop.counted().constantMaxTripCount() - 1) + constantInit(); |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
159 } |
16341
627f255ee298
made InductionVariable.deleteUnusedNodes() abstract
Doug Simon <doug.simon@oracle.com>
parents:
16248
diff
changeset
|
160 |
627f255ee298
made InductionVariable.deleteUnusedNodes() abstract
Doug Simon <doug.simon@oracle.com>
parents:
16248
diff
changeset
|
161 @Override |
627f255ee298
made InductionVariable.deleteUnusedNodes() abstract
Doug Simon <doug.simon@oracle.com>
parents:
16248
diff
changeset
|
162 public void deleteUnusedNodes() { |
627f255ee298
made InductionVariable.deleteUnusedNodes() abstract
Doug Simon <doug.simon@oracle.com>
parents:
16248
diff
changeset
|
163 } |
18953
fe3a00661c32
Add toString and some accessors to InductionVariable subclasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18845
diff
changeset
|
164 |
fe3a00661c32
Add toString and some accessors to InductionVariable subclasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18845
diff
changeset
|
165 @Override |
fe3a00661c32
Add toString and some accessors to InductionVariable subclasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18845
diff
changeset
|
166 public String toString() { |
fe3a00661c32
Add toString and some accessors to InductionVariable subclasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18845
diff
changeset
|
167 return String.format("BasicInductionVariable %s %s %s %s", initNode(), phi, op.getNodeClass().shortName(), strideNode()); |
fe3a00661c32
Add toString and some accessors to InductionVariable subclasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18845
diff
changeset
|
168 } |
5610
9f3250602d69
Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
169 } |