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

Unified Diff: src/arm/lithium-arm.cc

Issue 11293061: Emit VMLA for multiply-add on ARM (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fold instruction when forming Lithium instead (+tests) 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 side-by-side diff with in-line comments
Download patch
Index: src/arm/lithium-arm.cc
diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc
index 17f3325b754c3449f682425313062cf438c8d581..70ced1cf9e6af0072f3ae35783fe6ef30464e293 100644
--- a/src/arm/lithium-arm.cc
+++ b/src/arm/lithium-arm.cc
@@ -1303,8 +1303,21 @@ LInstruction* LChunkBuilder::DoMul(HMul* instr) {
return DefineAsRegister(mul);
} else if (instr->representation().IsDouble()) {
- return DoArithmeticD(Token::MUL, instr);
+ if (instr->UseCount() == 1 && instr->uses().value()->IsAdd()) {
+ HAdd* add = HAdd::cast(instr->uses().value());
+ if (instr == add->left()) {
+ // This mul is the lhs of an add. The add and mul will be folded
+ // into a multiply-add.
+ return NULL;
+ }
+ if (instr == add->right() && !add->left()->IsMul()) {
+ // This mul is the rhs of an add, where the lhs is not another mul.
+ // The add and mul will be folded into a multiply-add.
+ return NULL;
+ }
+ }
+ return DoArithmeticD(Token::MUL, instr);
} else {
return DoArithmeticT(Token::MUL, instr);
}
@@ -1344,6 +1357,25 @@ LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
}
return result;
} else if (instr->representation().IsDouble()) {
+ // Fold a * b + c into LMultiplyAddD.
+ if (instr->left()->IsMul()) {
Sven Panne 2012/11/13 13:03:52 Style issue: Please use a helper function here and
hans 2012/11/13 14:59:58 Done. I noticed that you changed from UseRegister
+ HMul* mul = HMul::cast(instr->left());
+ LOperand* a = UseRegisterAtStart(mul->left());
+ LOperand* b = UseRegisterAtStart(mul->right());
+ LOperand* c = UseRegisterAtStart(instr->right());
+ LMultiplyAddD* result = new(zone()) LMultiplyAddD(c, a, b);
+ return DefineSameAsFirst(result);
+ }
+ // Fold c + a * b into LMultiplyAdd.
+ if (instr->right()->IsMul()) {
Jakob Kummerow 2012/11/13 13:05:21 Please add an ASSERT(!instr->left()->IsMul()) insi
hans 2012/11/13 14:59:58 Done.
+ HMul* mul = HMul::cast(instr->right());
+ LOperand* c = UseRegisterAtStart(instr->left());
+ LOperand* a = UseRegisterAtStart(mul->left());
+ LOperand* b = UseRegisterAtStart(mul->right());
+ LMultiplyAddD* result = new(zone()) LMultiplyAddD(c, a, b);
+ return DefineSameAsFirst(result);
+ }
+
return DoArithmeticD(Token::ADD, instr);
} else {
ASSERT(instr->representation().IsTagged());

Powered by Google App Engine
This is Rietveld 408576698