| Index: pkg/compiler/lib/src/ssa/value_range_analyzer.dart
|
| diff --git a/pkg/compiler/lib/src/ssa/value_range_analyzer.dart b/pkg/compiler/lib/src/ssa/value_range_analyzer.dart
|
| index 3f041a062f07a78d68f9fa31ad680fdf7fb753c9..7e53d06bac62445d1de327e18783a02ace8c910c 100644
|
| --- a/pkg/compiler/lib/src/ssa/value_range_analyzer.dart
|
| +++ b/pkg/compiler/lib/src/ssa/value_range_analyzer.dart
|
| @@ -814,8 +814,8 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
|
| HInstruction right = invoke.inputs[2];
|
| Range divisor = ranges[right];
|
| if (divisor != null) {
|
| - // For Integer values we can be precise in the upper bound,
|
| - // so special case those.
|
| + // For Integer values we can be precise in the upper bound, so special
|
| + // case those.
|
| if (left.isInteger(closedWorld) && right.isInteger(closedWorld)) {
|
| if (divisor.isPositive) {
|
| return info.newNormalizedRange(
|
| @@ -836,6 +836,30 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
|
| return info.newUnboundRange();
|
| }
|
|
|
| + Range visitRemainder(HRemainder instruction) {
|
| + HInstruction left = instruction.inputs[0];
|
| + HInstruction right = instruction.inputs[1];
|
| + Range dividend = ranges[left];
|
| + // If both operands are >=0, the result is >= 0 and bounded by the divisor.
|
| + if ((dividend != null && dividend.isPositive) ||
|
| + left.isPositiveInteger(closedWorld)) {
|
| + Range divisor = ranges[right];
|
| + if (divisor != null) {
|
| + if (divisor.isPositive) {
|
| + // For Integer values we can be precise in the upper bound.
|
| + if (left.isInteger(closedWorld) && right.isInteger(closedWorld)) {
|
| + return info.newNormalizedRange(
|
| + info.intZero, divisor.upper - info.intOne);
|
| + }
|
| + if (left.isNumber(closedWorld) && right.isNumber(closedWorld)) {
|
| + return info.newNormalizedRange(info.intZero, divisor.upper);
|
| + }
|
| + }
|
| + }
|
| + }
|
| + return info.newUnboundRange();
|
| + }
|
| +
|
| Range visitInvokeDynamicMethod(HInvokeDynamicMethod invoke) {
|
| if ((invoke.inputs.length == 3) && (invoke.selector.name == "%"))
|
| return handleInvokeModulo(invoke);
|
|
|