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

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, 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 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 if ((left_range == NULL) || (right_range == NULL)) { 2180 if ((left_range == NULL) || (right_range == NULL)) {
2181 range_ = new Range(RangeBoundary::MinSmi(), RangeBoundary::MaxSmi()); 2181 range_ = new Range(RangeBoundary::MinSmi(), RangeBoundary::MaxSmi());
2182 return; 2182 return;
2183 } 2183 }
2184 2184
2185 RangeBoundary new_min; 2185 RangeBoundary new_min;
2186 RangeBoundary new_max; 2186 RangeBoundary new_max;
2187 switch (op_kind()) { 2187 switch (op_kind()) {
2188 case Token::kADD: 2188 case Token::kADD:
2189 new_min = 2189 new_min =
2190 RangeBoundary::Add(Range::ConstantMin(left_range), 2190 RangeBoundary::Add(Range::ConstantMin(left_range),
2191 Range::ConstantMin(right_range), 2191 Range::ConstantMin(right_range),
2192 RangeBoundary::OverflowedMinSmi()); 2192 RangeBoundary::OverflowedMinSmi());
2193 new_max = 2193 new_max =
2194 RangeBoundary::Add(Range::ConstantMax(left_range), 2194 RangeBoundary::Add(Range::ConstantMax(left_range),
2195 Range::ConstantMax(right_range), 2195 Range::ConstantMax(right_range),
2196 RangeBoundary::OverflowedMaxSmi()); 2196 RangeBoundary::OverflowedMaxSmi());
2197 break; 2197 break;
2198 2198
2199 case Token::kSUB: 2199 case Token::kSUB:
2200 new_min = 2200 new_min =
2201 RangeBoundary::Sub(Range::ConstantMin(left_range), 2201 RangeBoundary::Sub(Range::ConstantMin(left_range),
2202 Range::ConstantMax(right_range), 2202 Range::ConstantMax(right_range),
2203 RangeBoundary::OverflowedMinSmi()); 2203 RangeBoundary::OverflowedMinSmi());
2204 new_max = 2204 new_max =
2205 RangeBoundary::Sub(Range::ConstantMax(left_range), 2205 RangeBoundary::Sub(Range::ConstantMax(left_range),
2206 Range::ConstantMin(right_range), 2206 Range::ConstantMin(right_range),
2207 RangeBoundary::OverflowedMaxSmi()); 2207 RangeBoundary::OverflowedMaxSmi());
2208 break; 2208 break;
2209 2209
2210 case Token::kBIT_AND:
2211 if (Range::ConstantMin(right_range).value() >= 0) {
2212 new_min = RangeBoundary::FromConstant(0);
2213 new_max = Range::ConstantMax(right_range);
2214 break;
2215 }
2216 if (Range::ConstantMin(left_range).value() >= 0) {
2217 new_min = RangeBoundary::FromConstant(0);
2218 new_max = Range::ConstantMax(left_range);
2219 break;
2220 }
2221
2222 if (range_ == NULL) {
2223 range_ = Range::Unknown();
2224 }
2225 return;
2226
2210 default: 2227 default:
2211 if (range_ == NULL) { 2228 if (range_ == NULL) {
2212 range_ = Range::Unknown(); 2229 range_ = Range::Unknown();
2213 } 2230 }
2214 return; 2231 return;
2215 } 2232 }
2216 2233
2217 ASSERT(!new_min.IsUnknown() && !new_max.IsUnknown()); 2234 ASSERT(!new_min.IsUnknown() && !new_max.IsUnknown());
2218 set_overflow(new_min.Overflowed() || new_max.Overflowed()); 2235 set_overflow(new_min.Overflowed() || new_max.Overflowed());
2219 2236
2220 range_ = new Range(new_min.Clamp(), new_max.Clamp()); 2237 range_ = new Range(new_min.Clamp(), new_max.Clamp());
2221 } 2238 }
2222 2239
2223 2240
2241 // Inclusive.
2242 bool Range::IsWithin(intptr_t min_int, intptr_t max_int) const {
2243 if (!min().IsConstant() || (min().value() < min_int)) return false;
Vyacheslav Egorov (Google) 2012/10/26 12:21:42 I suggest using LowerBound() and UpperBound() here
srdjan 2012/10/30 18:21:13 Done.
2244 if (!max().IsConstant() || (max().value() > max_int)) return false;
2245 return true;
2246 }
2247
2248
2224 #undef __ 2249 #undef __
2225 2250
2226 } // namespace dart 2251 } // 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