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

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

Issue 227553003: Fixed flooring division by -1 on ARM. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 8 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
« no previous file with comments | « no previous file | src/arm64/lithium-codegen-arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 if (divisor > 1) { 1462 if (divisor > 1) {
1463 __ mov(result, Operand(dividend, ASR, shift)); 1463 __ mov(result, Operand(dividend, ASR, shift));
1464 return; 1464 return;
1465 } 1465 }
1466 1466
1467 // If the divisor is negative, we have to negate and handle edge cases. 1467 // If the divisor is negative, we have to negate and handle edge cases.
1468 __ rsb(result, dividend, Operand::Zero(), SetCC); 1468 __ rsb(result, dividend, Operand::Zero(), SetCC);
1469 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 1469 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
1470 DeoptimizeIf(eq, instr->environment()); 1470 DeoptimizeIf(eq, instr->environment());
1471 } 1471 }
1472 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { 1472
1473 // Note that we could emit branch-free code, but that would need one more 1473 // If the negation could not overflow, simply shifting is OK.
1474 // register. 1474 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) {
1475 if (divisor == -1) {
1476 DeoptimizeIf(vs, instr->environment());
1477 __ mov(result, Operand(dividend, ASR, shift));
1478 } else {
1479 __ mov(result, Operand(kMinInt / divisor), LeaveCC, vs);
1480 __ mov(result, Operand(dividend, ASR, shift), LeaveCC, vc);
1481 }
1482 } else {
1483 __ mov(result, Operand(dividend, ASR, shift)); 1475 __ mov(result, Operand(dividend, ASR, shift));
1476 return;
1484 } 1477 }
1478
1479 // Dividing by -1 is basically negation, unless we overflow.
1480 if (divisor == -1) {
1481 DeoptimizeIf(vs, instr->environment());
1482 return;
1483 }
1484
1485 __ mov(result, Operand(kMinInt / divisor), LeaveCC, vs);
1486 __ mov(result, Operand(dividend, ASR, shift), LeaveCC, vc);
1485 } 1487 }
1486 1488
1487 1489
1488 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) { 1490 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) {
1489 Register dividend = ToRegister(instr->dividend()); 1491 Register dividend = ToRegister(instr->dividend());
1490 int32_t divisor = instr->divisor(); 1492 int32_t divisor = instr->divisor();
1491 Register result = ToRegister(instr->result()); 1493 Register result = ToRegister(instr->result());
1492 ASSERT(!dividend.is(result)); 1494 ASSERT(!dividend.is(result));
1493 1495
1494 if (divisor == 0) { 1496 if (divisor == 0) {
(...skipping 4355 matching lines...) Expand 10 before | Expand all | Expand 10 after
5850 __ ldr(result, FieldMemOperand(scratch, 5852 __ ldr(result, FieldMemOperand(scratch,
5851 FixedArray::kHeaderSize - kPointerSize)); 5853 FixedArray::kHeaderSize - kPointerSize));
5852 __ bind(deferred->exit()); 5854 __ bind(deferred->exit());
5853 __ bind(&done); 5855 __ bind(&done);
5854 } 5856 }
5855 5857
5856 5858
5857 #undef __ 5859 #undef __
5858 5860
5859 } } // namespace v8::internal 5861 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/arm64/lithium-codegen-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698