< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.loop/src/org/graalvm/compiler/loop/BasicInductionVariable.java

Print this page




 126         return rawStride.isConstant();
 127     }
 128 
 129     @Override
 130     public long constantInit() {
 131         return init.asJavaConstant().asLong();
 132     }
 133 
 134     @Override
 135     public long constantStride() {
 136         if (op instanceof AddNode) {
 137             return rawStride.asJavaConstant().asLong();
 138         }
 139         if (op instanceof SubNode) {
 140             return -rawStride.asJavaConstant().asLong();
 141         }
 142         throw GraalError.shouldNotReachHere();
 143     }
 144 
 145     @Override
 146     public ValueNode extremumNode(boolean assumePositiveTripCount, Stamp stamp) {
 147         Stamp fromStamp = phi.stamp(NodeView.DEFAULT);
 148         StructuredGraph graph = graph();
 149         ValueNode stride = strideNode();
 150         ValueNode initNode = this.initNode();
 151         if (!fromStamp.isCompatible(stamp)) {
 152             stride = IntegerConvertNode.convert(stride, stamp, graph(), NodeView.DEFAULT);
 153             initNode = IntegerConvertNode.convert(initNode, stamp, graph(), NodeView.DEFAULT);
 154         }
 155         ValueNode maxTripCount = loop.counted().maxTripCountNode(assumePositiveTripCount);
 156         if (!maxTripCount.stamp(NodeView.DEFAULT).isCompatible(stamp)) {
 157             maxTripCount = IntegerConvertNode.convert(maxTripCount, stamp, graph(), NodeView.DEFAULT);
 158         }
 159         return add(graph, mul(graph, stride, sub(graph, maxTripCount, ConstantNode.forIntegerStamp(stamp, 1, graph))), initNode);
 160     }
 161 
 162     @Override
 163     public ValueNode exitValueNode() {
 164         Stamp stamp = phi.stamp(NodeView.DEFAULT);
 165         ValueNode maxTripCount = loop.counted().maxTripCountNode();
 166         if (!maxTripCount.stamp(NodeView.DEFAULT).isCompatible(stamp)) {
 167             maxTripCount = IntegerConvertNode.convert(maxTripCount, stamp, graph(), NodeView.DEFAULT);
 168         }
 169         return add(graph(), mul(graph(), strideNode(), maxTripCount), initNode());
 170     }
 171 
 172     @Override
 173     public boolean isConstantExtremum() {
 174         return isConstantInit() && isConstantStride() && loop.counted().isConstantMaxTripCount();
 175     }


 126         return rawStride.isConstant();
 127     }
 128 
 129     @Override
 130     public long constantInit() {
 131         return init.asJavaConstant().asLong();
 132     }
 133 
 134     @Override
 135     public long constantStride() {
 136         if (op instanceof AddNode) {
 137             return rawStride.asJavaConstant().asLong();
 138         }
 139         if (op instanceof SubNode) {
 140             return -rawStride.asJavaConstant().asLong();
 141         }
 142         throw GraalError.shouldNotReachHere();
 143     }
 144 
 145     @Override
 146     public ValueNode extremumNode(boolean assumeLoopEntered, Stamp stamp) {
 147         Stamp fromStamp = phi.stamp(NodeView.DEFAULT);
 148         StructuredGraph graph = graph();
 149         ValueNode stride = strideNode();
 150         ValueNode initNode = this.initNode();
 151         if (!fromStamp.isCompatible(stamp)) {
 152             stride = IntegerConvertNode.convert(stride, stamp, graph(), NodeView.DEFAULT);
 153             initNode = IntegerConvertNode.convert(initNode, stamp, graph(), NodeView.DEFAULT);
 154         }
 155         ValueNode maxTripCount = loop.counted().maxTripCountNode(assumeLoopEntered);
 156         if (!maxTripCount.stamp(NodeView.DEFAULT).isCompatible(stamp)) {
 157             maxTripCount = IntegerConvertNode.convert(maxTripCount, stamp, graph(), NodeView.DEFAULT);
 158         }
 159         return add(graph, mul(graph, stride, sub(graph, maxTripCount, ConstantNode.forIntegerStamp(stamp, 1, graph))), initNode);
 160     }
 161 
 162     @Override
 163     public ValueNode exitValueNode() {
 164         Stamp stamp = phi.stamp(NodeView.DEFAULT);
 165         ValueNode maxTripCount = loop.counted().maxTripCountNode();
 166         if (!maxTripCount.stamp(NodeView.DEFAULT).isCompatible(stamp)) {
 167             maxTripCount = IntegerConvertNode.convert(maxTripCount, stamp, graph(), NodeView.DEFAULT);
 168         }
 169         return add(graph(), mul(graph(), strideNode(), maxTripCount), initNode());
 170     }
 171 
 172     @Override
 173     public boolean isConstantExtremum() {
 174         return isConstantInit() && isConstantStride() && loop.counted().isConstantMaxTripCount();
 175     }
< prev index next >