annotate graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java @ 14978:e302df8bf51c

separate subclasses for value and guard phis and proxies
author Lukas Stadler <lukas.stadler@oracle.com>
date Fri, 04 Apr 2014 18:32:32 +0200
parents 958c99d0790c
children 96bb07a5d667
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5610
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
1 /*
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
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
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
25 import com.oracle.graal.graph.*;
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
26 import com.oracle.graal.nodes.*;
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
27 import com.oracle.graal.nodes.calc.*;
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
28 import com.oracle.graal.nodes.type.*;
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
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14000
diff changeset
32 private ValuePhiNode phi;
5610
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
33 private ValueNode init;
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
34 private ValueNode rawStride;
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
35 private IntegerArithmeticNode op;
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
36
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14000
diff changeset
37 public BasicInductionVariable(LoopEx loop, ValuePhiNode phi, ValueNode init, ValueNode rawStride, IntegerArithmeticNode 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
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 11263
diff changeset
50 @Override
5610
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
51 public Direction direction() {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
52 Stamp stamp = rawStride.stamp();
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
53 if (stamp instanceof IntegerStamp) {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
54 IntegerStamp integerStamp = (IntegerStamp) stamp;
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
55 Direction dir = null;
6299
1ed726759f65 Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5610
diff changeset
56 if (integerStamp.isStrictlyPositive()) {
5610
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
57 dir = Direction.Up;
6299
1ed726759f65 Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5610
diff changeset
58 } else if (integerStamp.isStrictlyNegative()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6523
diff changeset
59 dir = Direction.Down;
5610
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
60 }
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
61 if (dir != null) {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
62 if (op instanceof IntegerAddNode) {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
63 return dir;
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
64 } else {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
65 assert op instanceof IntegerSubNode;
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
66 return dir.opposite();
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
67 }
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
68 }
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
69 }
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
70 return null;
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 @Override
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14000
diff changeset
74 public ValuePhiNode valueNode() {
5610
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
75 return phi;
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
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
78 @Override
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
79 public ValueNode initNode() {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
80 return init;
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
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
83 @Override
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
84 public ValueNode strideNode() {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
85 if (op instanceof IntegerAddNode) {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
86 return rawStride;
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
87 }
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
88 if (op instanceof IntegerSubNode) {
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 11263
diff changeset
89 return graph().unique(new NegateNode(rawStride));
5610
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
90 }
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
91 throw GraalInternalError.shouldNotReachHere();
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
92 }
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
93
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
94 @Override
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
95 public boolean isConstantInit() {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
96 return init.isConstant();
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
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
99 @Override
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
100 public boolean isConstantStride() {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
101 return rawStride.isConstant();
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
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
104 @Override
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
105 public long constantInit() {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
106 return init.asConstant().asLong();
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
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
109 @Override
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
110 public long constantStride() {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
111 if (op instanceof IntegerAddNode) {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
112 return rawStride.asConstant().asLong();
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
113 }
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
114 if (op instanceof IntegerSubNode) {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
115 return -rawStride.asConstant().asLong();
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
116 }
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
117 throw GraalInternalError.shouldNotReachHere();
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
118 }
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
119
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
120 @Override
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 12720
diff changeset
121 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
122 Stamp fromStamp = phi.stamp();
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 11263
diff changeset
123 StructuredGraph graph = graph();
9446
27733a62ba72 Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
124 ValueNode stride = strideNode();
27733a62ba72 Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
125 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
126 if (!fromStamp.isCompatible(stamp)) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 12720
diff changeset
127 stride = IntegerConvertNode.convert(stride, stamp);
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 12720
diff changeset
128 initNode = IntegerConvertNode.convert(initNode, stamp);
9446
27733a62ba72 Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
129 }
12720
8898d449f95d Fix wrong conversion in extremum and exit values of induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents: 12656
diff changeset
130 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
131 if (!maxTripCount.stamp().isCompatible(stamp)) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 12720
diff changeset
132 maxTripCount = IntegerConvertNode.convert(maxTripCount, stamp);
12720
8898d449f95d Fix wrong conversion in extremum and exit values of induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents: 12656
diff changeset
133 }
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 12720
diff changeset
134 return IntegerArithmeticNode.add(graph, IntegerArithmeticNode.mul(graph, stride, IntegerArithmeticNode.sub(graph, maxTripCount, ConstantNode.forIntegerStamp(stamp, 1, graph))), initNode);
5610
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
135 }
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
136
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
137 @Override
11263
acf09b065eba Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents: 9446
diff changeset
138 public ValueNode exitValueNode() {
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 12720
diff changeset
139 Stamp stamp = phi.stamp();
11263
acf09b065eba Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents: 9446
diff changeset
140 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
141 if (!maxTripCount.stamp().isCompatible(stamp)) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 12720
diff changeset
142 maxTripCount = IntegerConvertNode.convert(maxTripCount, stamp);
12720
8898d449f95d Fix wrong conversion in extremum and exit values of induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents: 12656
diff changeset
143 }
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 11263
diff changeset
144 return IntegerArithmeticNode.add(graph(), IntegerArithmeticNode.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
145 }
acf09b065eba Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents: 9446
diff changeset
146
acf09b065eba Calculate exit value of counted loop induction variables.
Roland Schatz <roland.schatz@oracle.com>
parents: 9446
diff changeset
147 @Override
5610
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
148 public boolean isConstantExtremum() {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
149 return isConstantInit() && isConstantStride() && loop.counted().isConstantMaxTripCount();
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
150 }
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
151
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
152 @Override
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
153 public long constantExtremum() {
9446
27733a62ba72 Fixes and improvements for induction variables
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
154 return constantStride() * (loop.counted().constantMaxTripCount() - 1) + constantInit();
5610
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 }