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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart

Issue 87783003: Add UInt32 and UInt31 types to better infer bit operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/codegen.dart (revision 30666)
+++ sdk/lib/_internal/compiler/implementation/ssa/codegen.dart (working copy)
@@ -189,18 +189,6 @@
return generateAtUseSite.contains(instruction);
}
- bool isNonNegativeInt32Constant(HInstruction instruction) {
- if (instruction.isConstantInteger()) {
- HConstant constantInstruction = instruction;
- PrimitiveConstant primitiveConstant = constantInstruction.constant;
- int value = primitiveConstant.value;
- if (value >= 0 && value < (1 << 31)) {
- return true;
- }
- }
- return false;
- }
-
bool hasNonBitOpUser(HInstruction instruction, Set<HPhi> phiSet) {
for (HInstruction user in instruction.usedBy) {
if (user is HPhi) {
@@ -215,22 +203,10 @@
return false;
}
- // We want the outcome of bit-operations to be positive. However, if
- // the result of a bit-operation is only used by other bit
- // operations we do not have to convert to an unsigned
- // integer. Also, if we are using & with a positive constant we know
- // that the result is positive already and need no conversion.
- bool requiresUintConversion(HInstruction instruction) {
- if (instruction is HShiftRight) {
- return false;
- }
- if (instruction is HBitAnd) {
- HBitAnd bitAnd = instruction;
- if (isNonNegativeInt32Constant(bitAnd.left) ||
- isNonNegativeInt32Constant(bitAnd.right)) {
- return false;
- }
- }
+ bool requiresUintConversion(instruction) {
+ if (instruction.isUInt31(compiler)) return false;
+ // If the result of a bit-operation is only used by other bit
+ // operations, we do not have to convert to an unsigned integer.
return hasNonBitOpUser(instruction, new Set<HPhi>());
}

Powered by Google App Engine
This is Rietveld 408576698