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

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

Issue 14320021: Ignore observed Double output in binary operations when all uses are truncating to Integer32 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment; blacklisted Mul too Created 7 years, 8 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 | « src/hydrogen-instructions.h ('k') | 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 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 Representation new_rep = RepresentationFromInputs(); 2221 Representation new_rep = RepresentationFromInputs();
2222 UpdateRepresentation(new_rep, h_infer, "inputs"); 2222 UpdateRepresentation(new_rep, h_infer, "inputs");
2223 // When the operation has information about its own output type, don't look 2223 // When the operation has information about its own output type, don't look
2224 // at uses. 2224 // at uses.
2225 if (!observed_output_representation_.IsNone()) return; 2225 if (!observed_output_representation_.IsNone()) return;
2226 new_rep = RepresentationFromUses(); 2226 new_rep = RepresentationFromUses();
2227 UpdateRepresentation(new_rep, h_infer, "uses"); 2227 UpdateRepresentation(new_rep, h_infer, "uses");
2228 } 2228 }
2229 2229
2230 2230
2231 bool HBinaryOperation::IgnoreObservedOutputRepresentation(
2232 Representation current_rep) {
2233 return observed_output_representation_.IsDouble() &&
2234 current_rep.IsInteger32() &&
2235 // Mul in Integer32 mode would be too precise.
2236 !this->IsMul() &&
2237 // TODO(jkummerow): Remove blacklisting of Div when the Div
2238 // instruction has learned not to deopt when the remainder is
2239 // non-zero but all uses are truncating.
2240 !this->IsDiv() &&
2241 CheckUsesForFlag(kTruncatingToInt32);
2242 }
2243
2244
2231 Representation HBinaryOperation::RepresentationFromInputs() { 2245 Representation HBinaryOperation::RepresentationFromInputs() {
2232 // Determine the worst case of observed input representations and 2246 // Determine the worst case of observed input representations and
2233 // the currently assumed output representation. 2247 // the currently assumed output representation.
2234 Representation rep = representation(); 2248 Representation rep = representation();
2235 if (observed_output_representation_.is_more_general_than(rep)) {
2236 rep = observed_output_representation_;
2237 }
2238 for (int i = 1; i <= 2; ++i) { 2249 for (int i = 1; i <= 2; ++i) {
2239 Representation input_rep = observed_input_representation(i); 2250 Representation input_rep = observed_input_representation(i);
2240 if (input_rep.is_more_general_than(rep)) rep = input_rep; 2251 if (input_rep.is_more_general_than(rep)) rep = input_rep;
2241 } 2252 }
2242 // If any of the actual input representation is more general than what we 2253 // If any of the actual input representation is more general than what we
2243 // have so far but not Tagged, use that representation instead. 2254 // have so far but not Tagged, use that representation instead.
2244 Representation left_rep = left()->representation(); 2255 Representation left_rep = left()->representation();
2245 Representation right_rep = right()->representation(); 2256 Representation right_rep = right()->representation();
2246 2257
2247 if (left_rep.is_more_general_than(rep) && 2258 if (left_rep.is_more_general_than(rep) &&
2248 left()->CheckFlag(kFlexibleRepresentation)) { 2259 left()->CheckFlag(kFlexibleRepresentation)) {
2249 rep = left_rep; 2260 rep = left_rep;
2250 } 2261 }
2251 if (right_rep.is_more_general_than(rep) && 2262 if (right_rep.is_more_general_than(rep) &&
2252 right()->CheckFlag(kFlexibleRepresentation)) { 2263 right()->CheckFlag(kFlexibleRepresentation)) {
2253 rep = right_rep; 2264 rep = right_rep;
2254 } 2265 }
2266 // Consider observed output representation, but ignore it if it's Double,
2267 // this instruction is not a division, and all its uses are truncating
2268 // to Integer32.
2269 if (observed_output_representation_.is_more_general_than(rep) &&
2270 !IgnoreObservedOutputRepresentation(rep)) {
2271 rep = observed_output_representation_;
2272 }
2255 return rep; 2273 return rep;
2256 } 2274 }
2257 2275
2258 2276
2259 void HBinaryOperation::AssumeRepresentation(Representation r) { 2277 void HBinaryOperation::AssumeRepresentation(Representation r) {
2260 set_observed_input_representation(r, r); 2278 set_observed_input_representation(r, r);
2261 HValue::AssumeRepresentation(r); 2279 HValue::AssumeRepresentation(r);
2262 } 2280 }
2263 2281
2264 2282
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
3597 3615
3598 3616
3599 void HCheckFunction::Verify() { 3617 void HCheckFunction::Verify() {
3600 HInstruction::Verify(); 3618 HInstruction::Verify();
3601 ASSERT(HasNoUses()); 3619 ASSERT(HasNoUses());
3602 } 3620 }
3603 3621
3604 #endif 3622 #endif
3605 3623
3606 } } // namespace v8::internal 3624 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698