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

Side by Side Diff: src/hydrogen-instructions.cc

Issue 16361003: Infer the range of XOR as limited by the highest possible changed bit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Sven's comment Created 7 years, 6 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 | « 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2292 matching lines...) Expand 10 before | Expand all | Expand 10 after
2303 2303
2304 void HMathMinMax::InferRepresentation(HInferRepresentation* h_infer) { 2304 void HMathMinMax::InferRepresentation(HInferRepresentation* h_infer) {
2305 ASSERT(CheckFlag(kFlexibleRepresentation)); 2305 ASSERT(CheckFlag(kFlexibleRepresentation));
2306 Representation new_rep = RepresentationFromInputs(); 2306 Representation new_rep = RepresentationFromInputs();
2307 UpdateRepresentation(new_rep, h_infer, "inputs"); 2307 UpdateRepresentation(new_rep, h_infer, "inputs");
2308 // Do not care about uses. 2308 // Do not care about uses.
2309 } 2309 }
2310 2310
2311 2311
2312 Range* HBitwise::InferRange(Zone* zone) { 2312 Range* HBitwise::InferRange(Zone* zone) {
2313 if (op() == Token::BIT_XOR) return HValue::InferRange(zone); 2313 if (op() == Token::BIT_XOR) {
2314 if (left()->HasRange() && right()->HasRange()) {
2315 // The maximum value has the high bit, and all bits below, set:
2316 // (1 << high) - 1.
2317 // If the range can be negative, the minimum int is a negative number with
2318 // the high bit, and all bits below, unset:
2319 // -(1 << high).
2320 // If it cannot be negative, conservatively choose 0 as minimum int.
2321 int64_t left_upper = left()->range()->upper();
2322 int64_t left_lower = left()->range()->lower();
2323 int64_t right_upper = right()->range()->upper();
2324 int64_t right_lower = right()->range()->lower();
2325
2326 if (left_upper < 0) left_upper = ~left_upper;
2327 if (left_lower < 0) left_lower = ~left_lower;
2328 if (right_upper < 0) right_upper = ~right_upper;
2329 if (right_lower < 0) right_lower = ~right_lower;
2330
2331 // Find the highest used bit.
2332 int high = static_cast<int>(log2(left_upper));
2333 high = Max(high, static_cast<int>(log2(left_lower)));
2334 high = Max(high, static_cast<int>(log2(right_upper)));
2335 high = Max(high, static_cast<int>(log2(right_lower)));
2336
2337 int64_t limit = 1;
2338 limit <<= high + 1;
2339 int32_t min = (left()->range()->CanBeNegative() ||
2340 right()->range()->CanBeNegative())
2341 ? static_cast<int32_t>(-limit) : 0;
2342 return new(zone) Range(min, static_cast<int32_t>(limit - 1));
2343 }
2344 return HValue::InferRange(zone);
2345 }
2314 const int32_t kDefaultMask = static_cast<int32_t>(0xffffffff); 2346 const int32_t kDefaultMask = static_cast<int32_t>(0xffffffff);
2315 int32_t left_mask = (left()->range() != NULL) 2347 int32_t left_mask = (left()->range() != NULL)
2316 ? left()->range()->Mask() 2348 ? left()->range()->Mask()
2317 : kDefaultMask; 2349 : kDefaultMask;
2318 int32_t right_mask = (right()->range() != NULL) 2350 int32_t right_mask = (right()->range() != NULL)
2319 ? right()->range()->Mask() 2351 ? right()->range()->Mask()
2320 : kDefaultMask; 2352 : kDefaultMask;
2321 int32_t result_mask = (op() == Token::BIT_AND) 2353 int32_t result_mask = (op() == Token::BIT_AND)
2322 ? left_mask & right_mask 2354 ? left_mask & right_mask
2323 : left_mask | right_mask; 2355 : left_mask | right_mask;
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after
3760 case kBackingStore: 3792 case kBackingStore:
3761 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); 3793 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString());
3762 stream->Add("[backing-store]"); 3794 stream->Add("[backing-store]");
3763 break; 3795 break;
3764 } 3796 }
3765 3797
3766 stream->Add("@%d", offset()); 3798 stream->Add("@%d", offset());
3767 } 3799 }
3768 3800
3769 } } // namespace v8::internal 3801 } } // namespace v8::internal
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