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

Side by Side Diff: runtime/vm/flow_graph_range_analysis.cc

Issue 794613002: Improve bitwise OR, AND ranges by using the same approximation we use for XOR. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_range_analysis.h" 5 #include "vm/flow_graph_range_analysis.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/il_printer.h" 8 #include "vm/il_printer.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 *result_max = Range::ConstantMax(right_range); 2416 *result_max = Range::ConstantMax(right_range);
2417 return; 2417 return;
2418 } 2418 }
2419 2419
2420 if (Range::ConstantMin(left_range).ConstantValue() >= 0) { 2420 if (Range::ConstantMin(left_range).ConstantValue() >= 0) {
2421 *result_min = RangeBoundary::FromConstant(0); 2421 *result_min = RangeBoundary::FromConstant(0);
2422 *result_max = Range::ConstantMax(left_range); 2422 *result_max = Range::ConstantMax(left_range);
2423 return; 2423 return;
2424 } 2424 }
2425 2425
2426 *result_min = RangeBoundary::MinConstant(RangeBoundary::kRangeBoundaryInt64); 2426 Xor(left_range, right_range, result_min, result_max);
Florian Schneider 2014/12/10 15:55:14 Maybe this should be renamed to BitOp because the
2427 *result_max = RangeBoundary::MaxConstant(RangeBoundary::kRangeBoundaryInt64);
2428 } 2427 }
2429 2428
2430 2429
2431 static int BitSize(const Range* range) { 2430 static int BitSize(const Range* range) {
2432 const int64_t min = Range::ConstantMin(range).ConstantValue(); 2431 const int64_t min = Range::ConstantMin(range).ConstantValue();
2433 const int64_t max = Range::ConstantMax(range).ConstantValue(); 2432 const int64_t max = Range::ConstantMax(range).ConstantValue();
2434 return Utils::Maximum(Utils::BitLength(min), Utils::BitLength(max)); 2433 return Utils::Maximum(Utils::BitLength(min), Utils::BitLength(max));
2435 } 2434 }
2436 2435
2437 2436
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 2623
2625 case Token::kBIT_AND: 2624 case Token::kBIT_AND:
2626 Range::And(left_range, right_range, &min, &max); 2625 Range::And(left_range, right_range, &min, &max);
2627 break; 2626 break;
2628 2627
2629 case Token::kBIT_XOR: 2628 case Token::kBIT_XOR:
2630 Range::Xor(left_range, right_range, &min, &max); 2629 Range::Xor(left_range, right_range, &min, &max);
2631 break; 2630 break;
2632 2631
2633 case Token::kBIT_OR: 2632 case Token::kBIT_OR:
2634 *result = Range::Full(RangeBoundary::kRangeBoundaryInt64); 2633 Range::Xor(left_range, right_range, &min, &max);
2635 return; 2634 break;
2636 2635
2637 default: 2636 default:
2638 *result = Range(RangeBoundary::NegativeInfinity(), 2637 *result = Range(RangeBoundary::NegativeInfinity(),
2639 RangeBoundary::PositiveInfinity()); 2638 RangeBoundary::PositiveInfinity());
2640 return; 2639 return;
2641 } 2640 }
2642 2641
2643 ASSERT(!min.IsUnknown() && !max.IsUnknown()); 2642 ASSERT(!min.IsUnknown() && !max.IsUnknown());
2644 2643
2645 *result = Range(min, max); 2644 *result = Range(min, max);
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
3145 } 3144 }
3146 } while (CanonicalizeMaxBoundary(&max) || 3145 } while (CanonicalizeMaxBoundary(&max) ||
3147 CanonicalizeMinBoundary(&canonical_length)); 3146 CanonicalizeMinBoundary(&canonical_length));
3148 3147
3149 // Failed to prove that maximum is bounded with array length. 3148 // Failed to prove that maximum is bounded with array length.
3150 return false; 3149 return false;
3151 } 3150 }
3152 3151
3153 3152
3154 } // namespace dart 3153 } // namespace dart
OLDNEW
« 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