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

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

Issue 2756543003: Lower shift-left when count is masked into valid range. (Closed)
Patch Set: Created 3 years, 9 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart
diff --git a/pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart b/pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart
index 6dbf37bbc4b3072c4824108aa2734e34fee21258..b6514c4d1dd3ec5daf59c24cb9d814f21ff5c7d0 100644
--- a/pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart
+++ b/pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart
@@ -539,11 +539,23 @@ abstract class BinaryBitOpSpecializer extends BinaryArithmeticSpecializer {
}
bool argumentLessThan32(HInstruction instruction) {
- if (!instruction.isConstantInteger()) return false;
- HConstant rightConstant = instruction;
- IntConstantValue intConstant = rightConstant.constant;
- int count = intConstant.primitiveValue;
- return count >= 0 && count <= 31;
+ return argumentInRange(instruction, 0, 31);
+ }
+
+ bool argumentInRange(HInstruction instruction, int low, int high) {
+ if (instruction.isConstantInteger()) {
+ HConstant rightConstant = instruction;
+ IntConstantValue intConstant = rightConstant.constant;
+ int value = intConstant.primitiveValue;
+ return value >= low && value <= high;
+ }
+ // TODO(sra): Integrate with the bit-width analysis in codegen.dart.
+ if (instruction is HBitAnd) {
+ return low == 0 &&
+ (argumentInRange(instruction.inputs[0], low, high) ||
+ argumentInRange(instruction.inputs[1], low, high));
+ }
+ return false;
}
bool isPositive(HInstruction instruction, ClosedWorld closedWorld) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698