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

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

Issue 11175013: Add range to kBIT_AND with positive constants. Use that range to eliminate compares in left shifts. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 2169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 new_min = 2180 new_min =
2181 RangeBoundary::Sub(Range::ConstantMin(left_range), 2181 RangeBoundary::Sub(Range::ConstantMin(left_range),
2182 Range::ConstantMax(right_range), 2182 Range::ConstantMax(right_range),
2183 RangeBoundary::OverflowedMinSmi()); 2183 RangeBoundary::OverflowedMinSmi());
2184 new_max = 2184 new_max =
2185 RangeBoundary::Sub(Range::ConstantMax(left_range), 2185 RangeBoundary::Sub(Range::ConstantMax(left_range),
2186 Range::ConstantMin(right_range), 2186 Range::ConstantMin(right_range),
2187 RangeBoundary::OverflowedMaxSmi()); 2187 RangeBoundary::OverflowedMaxSmi());
2188 break; 2188 break;
2189 2189
2190 case Token::kBIT_AND:
2191 if (Range::ConstantMin(right_range).value() >= 0) {
2192 new_min = RangeBoundary::FromConstant(0);
2193 new_max = Range::ConstantMax(right_range);
2194 break;
2195 }
2196 if (Range::ConstantMin(left_range).value() >= 0) {
2197 new_min = RangeBoundary::FromConstant(0);
2198 new_max = Range::ConstantMax(left_range);
2199 break;
2200 }
2201 if (range_ == NULL) {
Vyacheslav Egorov (Google) 2012/10/19 20:05:28 I sense a problem here. Range of a phi can start l
2202 range_ = Range::Unknown();
2203 return true;
2204 }
2205 return false;
2206
2190 default: 2207 default:
2191 if (range_ == NULL) { 2208 if (range_ == NULL) {
2192 range_ = Range::Unknown(); 2209 range_ = Range::Unknown();
2193 return true; 2210 return true;
2194 } 2211 }
2195 return false; 2212 return false;
2196 } 2213 }
2197 2214
2198 ASSERT(!new_min.IsUnknown() && !new_max.IsUnknown()); 2215 ASSERT(!new_min.IsUnknown() && !new_max.IsUnknown());
2199 set_overflow(new_min.Overflowed() || new_max.Overflowed()); 2216 set_overflow(new_min.Overflowed() || new_max.Overflowed());
2200 2217
2201 if (op == Definition::kRangeNarrow) { 2218 if (op == Definition::kRangeNarrow) {
2202 new_min = new_min.Clamp(); 2219 new_min = new_min.Clamp();
2203 new_max = new_max.Clamp(); 2220 new_max = new_max.Clamp();
2204 } 2221 }
2205 2222
2206 return Range::Update(&range_, new_min, new_max); 2223 return Range::Update(&range_, new_min, new_max);
2207 } 2224 }
2208 2225
2209 2226
2227 // Inclusive.
2228 bool Range::IsWithin(intptr_t min_int, intptr_t max_int) const {
2229 if (!min().IsConstant() || (min().value() < min_int)) return false;
2230 if (!max().IsConstant() || (max().value() > max_int)) return false;
2231 return true;
2232 }
2233
2234
2210 #undef __ 2235 #undef __
2211 2236
2212 } // namespace dart 2237 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698