Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 51ae7f5a44c29fc4b69f66651b95fcfef7a6f2fa..b74a5984beacf2964dd0d5ef31f330b773089aec 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -8282,6 +8282,24 @@ bool CanBeZero(HValue *right) { |
} |
+bool HGraphBuilder::MatchMultiplyAdd(HValue* left, HValue* right, HValue** a, |
+ HValue** b, HValue** c) { |
+ if (right->IsMul()) { |
+ HValue *tmp = left; |
+ left = right; |
+ right = tmp; |
+ } |
+ if (!left->IsMul()) |
+ return false; |
+ |
+ HMul* mul = HMul::cast(left); |
+ *a = mul->left(); |
+ *b = mul->right(); |
+ *c = right; |
+ return true; |
+} |
+ |
+ |
HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr, |
HValue* left, |
HValue* right) { |
@@ -8294,17 +8312,21 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr, |
} |
HInstruction* instr = NULL; |
switch (expr->op()) { |
- case Token::ADD: |
+ case Token::ADD: { |
+ HValue* a, *b, *c; |
if (info.IsString()) { |
AddInstruction(new(zone()) HCheckNonSmi(left)); |
AddInstruction(HCheckInstanceType::NewIsString(left, zone())); |
AddInstruction(new(zone()) HCheckNonSmi(right)); |
AddInstruction(HCheckInstanceType::NewIsString(right, zone())); |
instr = new(zone()) HStringAdd(context, left, right); |
+ } else if (info.IsDouble() && MatchMultiplyAdd(left, right, &a, &b, &c)) { |
+ instr = new(zone()) HMultiplyAddD(context, a, b, c); |
} else { |
instr = HAdd::NewHAdd(zone(), context, left, right); |
} |
break; |
+ } |
case Token::SUB: |
instr = HSub::NewHSub(zone(), context, left, right); |
break; |