Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1296 left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1296 left = UseRegisterAtStart(instr->LeastConstantOperand()); |
| 1297 } | 1297 } |
| 1298 LMulI* mul = new(zone()) LMulI(left, right, temp); | 1298 LMulI* mul = new(zone()) LMulI(left, right, temp); |
| 1299 if (instr->CheckFlag(HValue::kCanOverflow) || | 1299 if (instr->CheckFlag(HValue::kCanOverflow) || |
| 1300 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1300 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 1301 AssignEnvironment(mul); | 1301 AssignEnvironment(mul); |
| 1302 } | 1302 } |
| 1303 return DefineAsRegister(mul); | 1303 return DefineAsRegister(mul); |
| 1304 | 1304 |
| 1305 } else if (instr->representation().IsDouble()) { | 1305 } else if (instr->representation().IsDouble()) { |
| 1306 if (instr->UseCount() == 1 && instr->uses().value()->IsAdd()) { | |
| 1307 HAdd* add = HAdd::cast(instr->uses().value()); | |
| 1308 if (instr == add->left()) { | |
| 1309 // This mul is the lhs of an add. The add and mul will be folded | |
| 1310 // into a multiply-add. | |
| 1311 return NULL; | |
| 1312 } | |
| 1313 if (instr == add->right() && !add->left()->IsMul()) { | |
| 1314 // This mul is the rhs of an add, where the lhs is not another mul. | |
| 1315 // The add and mul will be folded into a multiply-add. | |
| 1316 return NULL; | |
| 1317 } | |
| 1318 } | |
| 1319 | |
| 1306 return DoArithmeticD(Token::MUL, instr); | 1320 return DoArithmeticD(Token::MUL, instr); |
| 1307 | |
| 1308 } else { | 1321 } else { |
| 1309 return DoArithmeticT(Token::MUL, instr); | 1322 return DoArithmeticT(Token::MUL, instr); |
| 1310 } | 1323 } |
| 1311 } | 1324 } |
| 1312 | 1325 |
| 1313 | 1326 |
| 1314 LInstruction* LChunkBuilder::DoSub(HSub* instr) { | 1327 LInstruction* LChunkBuilder::DoSub(HSub* instr) { |
| 1315 if (instr->representation().IsInteger32()) { | 1328 if (instr->representation().IsInteger32()) { |
| 1316 ASSERT(instr->left()->representation().IsInteger32()); | 1329 ASSERT(instr->left()->representation().IsInteger32()); |
| 1317 ASSERT(instr->right()->representation().IsInteger32()); | 1330 ASSERT(instr->right()->representation().IsInteger32()); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1337 ASSERT(instr->right()->representation().IsInteger32()); | 1350 ASSERT(instr->right()->representation().IsInteger32()); |
| 1338 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); | 1351 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); |
| 1339 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); | 1352 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); |
| 1340 LAddI* add = new(zone()) LAddI(left, right); | 1353 LAddI* add = new(zone()) LAddI(left, right); |
| 1341 LInstruction* result = DefineAsRegister(add); | 1354 LInstruction* result = DefineAsRegister(add); |
| 1342 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1355 if (instr->CheckFlag(HValue::kCanOverflow)) { |
| 1343 result = AssignEnvironment(result); | 1356 result = AssignEnvironment(result); |
| 1344 } | 1357 } |
| 1345 return result; | 1358 return result; |
| 1346 } else if (instr->representation().IsDouble()) { | 1359 } else if (instr->representation().IsDouble()) { |
| 1360 // Fold a * b + c into LMultiplyAddD. | |
| 1361 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
| |
| 1362 HMul* mul = HMul::cast(instr->left()); | |
| 1363 LOperand* a = UseRegisterAtStart(mul->left()); | |
| 1364 LOperand* b = UseRegisterAtStart(mul->right()); | |
| 1365 LOperand* c = UseRegisterAtStart(instr->right()); | |
| 1366 LMultiplyAddD* result = new(zone()) LMultiplyAddD(c, a, b); | |
| 1367 return DefineSameAsFirst(result); | |
| 1368 } | |
| 1369 // Fold c + a * b into LMultiplyAdd. | |
| 1370 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.
| |
| 1371 HMul* mul = HMul::cast(instr->right()); | |
| 1372 LOperand* c = UseRegisterAtStart(instr->left()); | |
| 1373 LOperand* a = UseRegisterAtStart(mul->left()); | |
| 1374 LOperand* b = UseRegisterAtStart(mul->right()); | |
| 1375 LMultiplyAddD* result = new(zone()) LMultiplyAddD(c, a, b); | |
| 1376 return DefineSameAsFirst(result); | |
| 1377 } | |
| 1378 | |
| 1347 return DoArithmeticD(Token::ADD, instr); | 1379 return DoArithmeticD(Token::ADD, instr); |
| 1348 } else { | 1380 } else { |
| 1349 ASSERT(instr->representation().IsTagged()); | 1381 ASSERT(instr->representation().IsTagged()); |
| 1350 return DoArithmeticT(Token::ADD, instr); | 1382 return DoArithmeticT(Token::ADD, instr); |
| 1351 } | 1383 } |
| 1352 } | 1384 } |
| 1353 | 1385 |
| 1354 | 1386 |
| 1355 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { | 1387 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { |
| 1356 LOperand* left = NULL; | 1388 LOperand* left = NULL; |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2262 | 2294 |
| 2263 | 2295 |
| 2264 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2296 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2265 LOperand* object = UseRegister(instr->object()); | 2297 LOperand* object = UseRegister(instr->object()); |
| 2266 LOperand* index = UseRegister(instr->index()); | 2298 LOperand* index = UseRegister(instr->index()); |
| 2267 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2299 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2268 } | 2300 } |
| 2269 | 2301 |
| 2270 | 2302 |
| 2271 } } // namespace v8::internal | 2303 } } // namespace v8::internal |
| OLD | NEW |