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

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 16741002: Skip some conditional deopts for Div/Mul when all uses are truncating (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: added regression test Created 7 years, 6 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 // Check for (kMinInt / -1). 1256 // Check for (kMinInt / -1).
1257 if (divisor == -1 && instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { 1257 if (divisor == -1 && instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) {
1258 __ cmpl(dividend, Immediate(kMinInt)); 1258 __ cmpl(dividend, Immediate(kMinInt));
1259 DeoptimizeIf(zero, instr->environment()); 1259 DeoptimizeIf(zero, instr->environment());
1260 } 1260 }
1261 test_value = - divisor - 1; 1261 test_value = - divisor - 1;
1262 power = WhichPowerOf2(-divisor); 1262 power = WhichPowerOf2(-divisor);
1263 } 1263 }
1264 1264
1265 if (test_value != 0) { 1265 if (test_value != 0) {
1266 // Deoptimize if remainder is not 0. 1266 if (instr->hydrogen()->CheckFlag(
1267 __ testl(dividend, Immediate(test_value)); 1267 HInstruction::kAllUsesTruncatingToInt32)) {
1268 DeoptimizeIf(not_zero, instr->environment()); 1268 Label done, negative;
1269 __ sarl(dividend, Immediate(power)); 1269 __ cmpl(dividend, Immediate(0));
1270 __ j(less, &negative, Label::kNear);
1271 __ sarl(dividend, Immediate(power));
1272 __ jmp(&done, Label::kNear);
1273
1274 __ bind(&negative);
1275 __ negl(dividend);
1276 __ sarl(dividend, Immediate(power));
1277 if (divisor > 0) __ negl(dividend);
1278 __ bind(&done);
1279 return; // Don't fall through to "__ neg" below.
1280 } else {
1281 // Deoptimize if remainder is not 0.
1282 __ testl(dividend, Immediate(test_value));
1283 DeoptimizeIf(not_zero, instr->environment());
1284 __ sarl(dividend, Immediate(power));
1285 }
1270 } 1286 }
1271 1287
1272 if (divisor < 0) __ negl(dividend); 1288 if (divisor < 0) __ negl(dividend);
1273 1289
1274 return; 1290 return;
1275 } 1291 }
1276 1292
1277 LOperand* right = instr->right(); 1293 LOperand* right = instr->right();
1278 ASSERT(ToRegister(instr->result()).is(rax)); 1294 ASSERT(ToRegister(instr->result()).is(rax));
1279 ASSERT(ToRegister(instr->left()).is(rax)); 1295 ASSERT(ToRegister(instr->left()).is(rax));
(...skipping 26 matching lines...) Expand all
1306 __ j(not_zero, &left_not_min_int, Label::kNear); 1322 __ j(not_zero, &left_not_min_int, Label::kNear);
1307 __ cmpl(right_reg, Immediate(-1)); 1323 __ cmpl(right_reg, Immediate(-1));
1308 DeoptimizeIf(zero, instr->environment()); 1324 DeoptimizeIf(zero, instr->environment());
1309 __ bind(&left_not_min_int); 1325 __ bind(&left_not_min_int);
1310 } 1326 }
1311 1327
1312 // Sign extend to rdx. 1328 // Sign extend to rdx.
1313 __ cdq(); 1329 __ cdq();
1314 __ idivl(right_reg); 1330 __ idivl(right_reg);
1315 1331
1316 if (!instr->is_flooring()) { 1332 if (instr->is_flooring()) {
1317 // Deoptimize if remainder is not 0.
1318 __ testl(rdx, rdx);
1319 DeoptimizeIf(not_zero, instr->environment());
1320 } else {
1321 Label done; 1333 Label done;
1322 __ testl(rdx, rdx); 1334 __ testl(rdx, rdx);
1323 __ j(zero, &done, Label::kNear); 1335 __ j(zero, &done, Label::kNear);
1324 __ xorl(rdx, right_reg); 1336 __ xorl(rdx, right_reg);
1325 __ sarl(rdx, Immediate(31)); 1337 __ sarl(rdx, Immediate(31));
1326 __ addl(rax, rdx); 1338 __ addl(rax, rdx);
1327 __ bind(&done); 1339 __ bind(&done);
1340 } else if (!instr->hydrogen()->CheckFlag(
1341 HInstruction::kAllUsesTruncatingToInt32)) {
1342 // Deoptimize if remainder is not 0.
1343 __ testl(rdx, rdx);
1344 DeoptimizeIf(not_zero, instr->environment());
1328 } 1345 }
1329 } 1346 }
1330 1347
1331 1348
1332 void LCodeGen::DoMulI(LMulI* instr) { 1349 void LCodeGen::DoMulI(LMulI* instr) {
1333 Register left = ToRegister(instr->left()); 1350 Register left = ToRegister(instr->left());
1334 LOperand* right = instr->right(); 1351 LOperand* right = instr->right();
1335 1352
1336 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 1353 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
1337 __ movl(kScratchRegister, left); 1354 __ movl(kScratchRegister, left);
(...skipping 4268 matching lines...) Expand 10 before | Expand all | Expand 10 after
5606 FixedArray::kHeaderSize - kPointerSize)); 5623 FixedArray::kHeaderSize - kPointerSize));
5607 __ bind(&done); 5624 __ bind(&done);
5608 } 5625 }
5609 5626
5610 5627
5611 #undef __ 5628 #undef __
5612 5629
5613 } } // namespace v8::internal 5630 } } // namespace v8::internal
5614 5631
5615 #endif // V8_TARGET_ARCH_X64 5632 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698