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

Side by Side Diff: src/ia32/lithium-codegen-ia32.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 | « src/arm64/lithium-codegen-arm64.cc ('k') | src/x64/lithium-codegen-x64.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 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 // If the divisor is positive, things are easy: There can be no deopts and we 1615 // If the divisor is positive, things are easy: There can be no deopts and we
1616 // can simply do an arithmetic right shift. 1616 // can simply do an arithmetic right shift.
1617 if (divisor == 1) return; 1617 if (divisor == 1) return;
1618 int32_t shift = WhichPowerOf2Abs(divisor); 1618 int32_t shift = WhichPowerOf2Abs(divisor);
1619 if (divisor > 1) { 1619 if (divisor > 1) {
1620 __ sar(dividend, shift); 1620 __ sar(dividend, shift);
1621 return; 1621 return;
1622 } 1622 }
1623 1623
1624 // If the divisor is negative, we have to negate and handle edge cases. 1624 // If the divisor is negative, we have to negate and handle edge cases.
1625 Label not_kmin_int, done;
1626 __ neg(dividend); 1625 __ neg(dividend);
1627 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 1626 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
1628 DeoptimizeIf(zero, instr->environment()); 1627 DeoptimizeIf(zero, instr->environment());
1629 } 1628 }
1630 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { 1629
1631 // Note that we could emit branch-free code, but that would need one more 1630 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) {
1632 // register. 1631 __ sar(dividend, shift);
1633 if (divisor == -1) { 1632 return;
1634 DeoptimizeIf(overflow, instr->environment());
1635 } else {
1636 __ j(no_overflow, &not_kmin_int, Label::kNear);
1637 __ mov(dividend, Immediate(kMinInt / divisor));
1638 __ jmp(&done, Label::kNear);
1639 }
1640 } 1633 }
1634
1635 // Dividing by -1 is basically negation, unless we overflow.
1636 if (divisor == -1) {
1637 DeoptimizeIf(overflow, instr->environment());
1638 return;
1639 }
1640
1641 Label not_kmin_int, done;
1642 __ j(no_overflow, &not_kmin_int, Label::kNear);
1643 __ mov(dividend, Immediate(kMinInt / divisor));
1644 __ jmp(&done, Label::kNear);
1641 __ bind(&not_kmin_int); 1645 __ bind(&not_kmin_int);
1642 __ sar(dividend, shift); 1646 __ sar(dividend, shift);
1643 __ bind(&done); 1647 __ bind(&done);
1644 } 1648 }
1645 1649
1646 1650
1647 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) { 1651 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) {
1648 Register dividend = ToRegister(instr->dividend()); 1652 Register dividend = ToRegister(instr->dividend());
1649 int32_t divisor = instr->divisor(); 1653 int32_t divisor = instr->divisor();
1650 ASSERT(ToRegister(instr->result()).is(edx)); 1654 ASSERT(ToRegister(instr->result()).is(edx));
(...skipping 4793 matching lines...) Expand 10 before | Expand all | Expand 10 after
6444 __ bind(deferred->exit()); 6448 __ bind(deferred->exit());
6445 __ bind(&done); 6449 __ bind(&done);
6446 } 6450 }
6447 6451
6448 6452
6449 #undef __ 6453 #undef __
6450 6454
6451 } } // namespace v8::internal 6455 } } // namespace v8::internal
6452 6456
6453 #endif // V8_TARGET_ARCH_IA32 6457 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm64/lithium-codegen-arm64.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698