Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Unified Diff: pkg/compiler/lib/src/ssa/value_range_analyzer.dart

Issue 2561533002: dart2js: Constant folding and specialization for remainder (Closed)
Patch Set: fix range analysis Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 1882fc6bb1f65d2ee84d7735a1589c1c95b19af2..589086fac5a39d5aff7fe19aaff80c70793e2631 100644
--- a/pkg/compiler/lib/src/ssa/value_range_analyzer.dart
+++ b/pkg/compiler/lib/src/ssa/value_range_analyzer.dart
@@ -687,7 +687,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
}
if (constantNum.isPositiveInfinity || constantNum.isNegativeInfinity) {
return info.newUnboundRange();
- }
+ }
if (constantNum.isMinusZero) constantNum = new IntConstantValue(0);
Value value = info.newIntValue(constantNum.primitiveValue);
return info.newNormalizedRange(value, value);
@@ -832,6 +832,21 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
return info.newUnboundRange();
}
+ Range visitRemainder(HRemainder instruction) {
+ HInstruction left = instruction.inputs[0];
+ HInstruction right = instruction.inputs[1];
+ if (left.isPositiveInteger(compiler) && right.isPositiveInteger(compiler)) {
+ Range divisor = ranges[right];
+ if (divisor != null) {
+ if (divisor.isPositive) {
+ return info.newNormalizedRange(
+ info.intZero, divisor.upper - info.intOne);
+ }
+ }
+ }
+ return info.newUnboundRange();
+ }
+
Range visitInvokeDynamicMethod(HInvokeDynamicMethod invoke) {
if ((invoke.inputs.length == 3) && (invoke.selector.name == "%"))
return handleInvokeModulo(invoke);

Powered by Google App Engine
This is Rietveld 408576698