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

Unified Diff: src/hydrogen-instructions.h

Issue 23717039: Tweak the Better{Left,Right}Operand() heuristic Base URL: git://github.com/v8/v8.git@master
Patch Set: Tune Better{Left,Right}Operand() heuristic Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index 2bfb284f829fcd1fad85f37d9e888c1c0ee851d2..e209ffb27d1f58b4344581d588ef906882ea6f74 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -967,6 +967,7 @@ class HValue : public ZoneObject {
Representation RepresentationFromUses();
Representation RepresentationFromUseRequirements();
bool HasNonSmiUse();
+ bool UsedBy(HValue* value);
virtual void UpdateRepresentation(Representation new_rep,
HInferRepresentationPhase* h_infer,
const char* reason);
@@ -3545,8 +3546,17 @@ class HBinaryOperation : public HTemplateInstruction<3> {
// Constant operands are better off on the right, they can be inlined in
// many situations on most platforms.
- if (left()->IsConstant()) return true;
- if (right()->IsConstant()) return false;
+ if (left()->IsConstant() &&
+ (!representation().IsDouble() || left()->UseCount() > 1)) {
+ return true;
+ }
+ if (right()->IsConstant() &&
+ (!representation().IsDouble() || right()->UseCount() > 1)) {
+ return false;
+ }
+
+ if (left()->IsPhi() && UsedBy(left())) return false;
+ if (right()->IsPhi() && UsedBy(right())) return true;
haitao.feng 2014/05/15 05:56:20 How about writing codes in this way? - if (left
// Otherwise, if there is only one use of the right operand, it would be
// better off on the left for platforms that only have 2-arg arithmetic
« no previous file with comments | « no previous file | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698