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

Side by Side Diff: src/compiler/machine-operator-reducer.cc

Issue 877753007: Reland "Initial switch to Chromium-style CHECK_* and DCHECK_* macros.". (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: VS201x now happy? Created 5 years, 10 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
« no previous file with comments | « src/compiler/loop-peeling.cc ('k') | src/compiler/move-optimizer.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/machine-operator-reducer.h" 5 #include "src/compiler/machine-operator-reducer.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/compiler/diamond.h" 10 #include "src/compiler/diamond.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 if (divisor > 0 && bit_cast<int32_t>(mag.multiplier) < 0) { 96 if (divisor > 0 && bit_cast<int32_t>(mag.multiplier) < 0) {
97 quotient = Int32Add(quotient, dividend); 97 quotient = Int32Add(quotient, dividend);
98 } else if (divisor < 0 && bit_cast<int32_t>(mag.multiplier) > 0) { 98 } else if (divisor < 0 && bit_cast<int32_t>(mag.multiplier) > 0) {
99 quotient = Int32Sub(quotient, dividend); 99 quotient = Int32Sub(quotient, dividend);
100 } 100 }
101 return Int32Add(Word32Sar(quotient, mag.shift), Word32Shr(dividend, 31)); 101 return Int32Add(Word32Sar(quotient, mag.shift), Word32Shr(dividend, 31));
102 } 102 }
103 103
104 104
105 Node* MachineOperatorReducer::Uint32Div(Node* dividend, uint32_t divisor) { 105 Node* MachineOperatorReducer::Uint32Div(Node* dividend, uint32_t divisor) {
106 DCHECK_LT(0, divisor); 106 DCHECK_LT(0u, divisor);
107 // If the divisor is even, we can avoid using the expensive fixup by shifting 107 // If the divisor is even, we can avoid using the expensive fixup by shifting
108 // the dividend upfront. 108 // the dividend upfront.
109 unsigned const shift = base::bits::CountTrailingZeros32(divisor); 109 unsigned const shift = base::bits::CountTrailingZeros32(divisor);
110 dividend = Word32Shr(dividend, shift); 110 dividend = Word32Shr(dividend, shift);
111 divisor >>= shift; 111 divisor >>= shift;
112 // Compute the magic number for the (shifted) divisor. 112 // Compute the magic number for the (shifted) divisor.
113 base::MagicNumbersForDivision<uint32_t> const mag = 113 base::MagicNumbersForDivision<uint32_t> const mag =
114 base::UnsignedDivisionByConstant(divisor, shift); 114 base::UnsignedDivisionByConstant(divisor, shift);
115 Node* quotient = graph()->NewNode(machine()->Uint32MulHigh(), dividend, 115 Node* quotient = graph()->NewNode(machine()->Uint32MulHigh(), dividend,
116 Uint32Constant(mag.multiplier)); 116 Uint32Constant(mag.multiplier));
117 if (mag.add) { 117 if (mag.add) {
118 DCHECK_LE(1, mag.shift); 118 DCHECK_LE(1u, mag.shift);
119 quotient = Word32Shr( 119 quotient = Word32Shr(
120 Int32Add(Word32Shr(Int32Sub(dividend, quotient), 1), quotient), 120 Int32Add(Word32Shr(Int32Sub(dividend, quotient), 1), quotient),
121 mag.shift - 1); 121 mag.shift - 1);
122 } else { 122 } else {
123 quotient = Word32Shr(quotient, mag.shift); 123 quotient = Word32Shr(quotient, mag.shift);
124 } 124 }
125 return quotient; 125 return quotient;
126 } 126 }
127 127
128 128
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 node->ReplaceInput(1, m.left().node()); 513 node->ReplaceInput(1, m.left().node());
514 node->TrimInputCount(2); 514 node->TrimInputCount(2);
515 return Changed(node); 515 return Changed(node);
516 } 516 }
517 if (m.right().HasValue()) { 517 if (m.right().HasValue()) {
518 int32_t const divisor = m.right().Value(); 518 int32_t const divisor = m.right().Value();
519 Node* const dividend = m.left().node(); 519 Node* const dividend = m.left().node();
520 Node* quotient = dividend; 520 Node* quotient = dividend;
521 if (base::bits::IsPowerOfTwo32(Abs(divisor))) { 521 if (base::bits::IsPowerOfTwo32(Abs(divisor))) {
522 uint32_t const shift = WhichPowerOf2Abs(divisor); 522 uint32_t const shift = WhichPowerOf2Abs(divisor);
523 DCHECK_NE(0, shift); 523 DCHECK_NE(0u, shift);
524 if (shift > 1) { 524 if (shift > 1) {
525 quotient = Word32Sar(quotient, 31); 525 quotient = Word32Sar(quotient, 31);
526 } 526 }
527 quotient = Int32Add(Word32Shr(quotient, 32u - shift), dividend); 527 quotient = Int32Add(Word32Shr(quotient, 32u - shift), dividend);
528 quotient = Word32Sar(quotient, shift); 528 quotient = Word32Sar(quotient, shift);
529 } else { 529 } else {
530 quotient = Int32Div(quotient, Abs(divisor)); 530 quotient = Int32Div(quotient, Abs(divisor));
531 } 531 }
532 if (divisor < 0) { 532 if (divisor < 0) {
533 node->set_op(machine()->Int32Sub()); 533 node->set_op(machine()->Int32Sub());
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 MachineOperatorBuilder* MachineOperatorReducer::machine() const { 942 MachineOperatorBuilder* MachineOperatorReducer::machine() const {
943 return jsgraph()->machine(); 943 return jsgraph()->machine();
944 } 944 }
945 945
946 946
947 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } 947 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
948 948
949 } // namespace compiler 949 } // namespace compiler
950 } // namespace internal 950 } // namespace internal
951 } // namespace v8 951 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/loop-peeling.cc ('k') | src/compiler/move-optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698