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

Side by Side Diff: test/cctest/compiler/test-run-machops.cc

Issue 1698483002: [arm][arm64] Improve CountTrailingZero implementation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comments addressed Created 4 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/x87/instruction-selector-x87.cc ('k') | test/cctest/test-assembler-arm.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. Use of this 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 #include <functional> 6 #include <functional>
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
(...skipping 11 matching lines...) Expand all
22 22
23 23
24 TEST(RunInt32Add) { 24 TEST(RunInt32Add) {
25 RawMachineAssemblerTester<int32_t> m; 25 RawMachineAssemblerTester<int32_t> m;
26 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); 26 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1));
27 m.Return(add); 27 m.Return(add);
28 CHECK_EQ(1, m.Call()); 28 CHECK_EQ(1, m.Call());
29 } 29 }
30 30
31 31
32 TEST(RunWord32ReverseBits) {
33 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
34 if (!m.machine()->Word32ReverseBits().IsSupported()) {
35 // We can only test the operator if it exists on the testing platform.
36 return;
37 }
38 m.Return(m.AddNode(m.machine()->Word32ReverseBits().op(), m.Parameter(0)));
39
40 CHECK_EQ(uint32_t(0x00000000), m.Call(uint32_t(0x00000000)));
41 CHECK_EQ(uint32_t(0x12345678), m.Call(uint32_t(0x1e6a2c48)));
42 CHECK_EQ(uint32_t(0xfedcba09), m.Call(uint32_t(0x905d3b7f)));
43 CHECK_EQ(uint32_t(0x01010101), m.Call(uint32_t(0x80808080)));
44 CHECK_EQ(uint32_t(0x01020408), m.Call(uint32_t(0x10204080)));
45 CHECK_EQ(uint32_t(0xf0703010), m.Call(uint32_t(0x080c0e0f)));
46 CHECK_EQ(uint32_t(0x1f8d0a3a), m.Call(uint32_t(0x5c50b1f8)));
47 CHECK_EQ(uint32_t(0xffffffff), m.Call(uint32_t(0xffffffff)));
48 }
49
50
32 TEST(RunWord32Ctz) { 51 TEST(RunWord32Ctz) {
33 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); 52 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32());
34 if (!m.machine()->Word32Ctz().IsSupported()) { 53 if (!m.machine()->Word32Ctz().IsSupported()) {
35 // We can only test the operator if it exists on the testing platform. 54 // We can only test the operator if it exists on the testing platform.
36 return; 55 return;
37 } 56 }
38 m.Return(m.AddNode(m.machine()->Word32Ctz().op(), m.Parameter(0))); 57 m.Return(m.AddNode(m.machine()->Word32Ctz().op(), m.Parameter(0)));
39 58
40 CHECK_EQ(32, m.Call(uint32_t(0x00000000))); 59 CHECK_EQ(32, m.Call(uint32_t(0x00000000)));
41 CHECK_EQ(31, m.Call(uint32_t(0x80000000))); 60 CHECK_EQ(31, m.Call(uint32_t(0x80000000)));
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 CHECK_EQ(1, m.Call(uint32_t(0x80000000))); 144 CHECK_EQ(1, m.Call(uint32_t(0x80000000)));
126 CHECK_EQ(32, m.Call(uint32_t(0xffffffff))); 145 CHECK_EQ(32, m.Call(uint32_t(0xffffffff)));
127 CHECK_EQ(6, m.Call(uint32_t(0x000dc100))); 146 CHECK_EQ(6, m.Call(uint32_t(0x000dc100)));
128 CHECK_EQ(9, m.Call(uint32_t(0xe00dc100))); 147 CHECK_EQ(9, m.Call(uint32_t(0xe00dc100)));
129 CHECK_EQ(11, m.Call(uint32_t(0xe00dc103))); 148 CHECK_EQ(11, m.Call(uint32_t(0xe00dc103)));
130 CHECK_EQ(9, m.Call(uint32_t(0x000dc107))); 149 CHECK_EQ(9, m.Call(uint32_t(0x000dc107)));
131 } 150 }
132 151
133 152
134 #if V8_TARGET_ARCH_64_BIT 153 #if V8_TARGET_ARCH_64_BIT
154 TEST(RunWord64ReverseBits) {
155 RawMachineAssemblerTester<uint64_t> m(MachineType::Uint64());
156 if (!m.machine()->Word64ReverseBits().IsSupported()) {
157 return;
158 }
159
160 m.Return(m.AddNode(m.machine()->Word64ReverseBits().op(), m.Parameter(0)));
161
162 CHECK_EQ(uint64_t(0x0000000000000000), m.Call(uint64_t(0x0000000000000000)));
163 CHECK_EQ(uint64_t(0x1234567890abcdef), m.Call(uint64_t(0xf7b3d5091e6a2c48)));
164 CHECK_EQ(uint64_t(0xfedcba0987654321), m.Call(uint64_t(0x84c2a6e1905d3b7f)));
165 CHECK_EQ(uint64_t(0x0101010101010101), m.Call(uint64_t(0x8080808080808080)));
166 CHECK_EQ(uint64_t(0x0102040803060c01), m.Call(uint64_t(0x803060c010204080)));
167 CHECK_EQ(uint64_t(0xf0703010e060200f), m.Call(uint64_t(0xf0040607080c0e0f)));
168 CHECK_EQ(uint64_t(0x2f8a6df01c21fa3b), m.Call(uint64_t(0xdc5f84380fb651f4)));
169 CHECK_EQ(uint64_t(0xffffffffffffffff), m.Call(uint64_t(0xffffffffffffffff)));
170 }
171
172
135 TEST(RunWord64Clz) { 173 TEST(RunWord64Clz) {
136 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint64()); 174 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint64());
137 m.Return(m.Word64Clz(m.Parameter(0))); 175 m.Return(m.Word64Clz(m.Parameter(0)));
138 176
139 CHECK_EQ(0, m.Call(uint64_t(0x8000100000000000))); 177 CHECK_EQ(0, m.Call(uint64_t(0x8000100000000000)));
140 CHECK_EQ(1, m.Call(uint64_t(0x4000050000000000))); 178 CHECK_EQ(1, m.Call(uint64_t(0x4000050000000000)));
141 CHECK_EQ(2, m.Call(uint64_t(0x2000030000000000))); 179 CHECK_EQ(2, m.Call(uint64_t(0x2000030000000000)));
142 CHECK_EQ(3, m.Call(uint64_t(0x1000000300000000))); 180 CHECK_EQ(3, m.Call(uint64_t(0x1000000300000000)));
143 CHECK_EQ(4, m.Call(uint64_t(0x0805000000000000))); 181 CHECK_EQ(4, m.Call(uint64_t(0x0805000000000000)));
144 CHECK_EQ(5, m.Call(uint64_t(0x0400600000000000))); 182 CHECK_EQ(5, m.Call(uint64_t(0x0400600000000000)));
(...skipping 6047 matching lines...) Expand 10 before | Expand all | Expand 10 after
6192 Node* call = r.AddNode(r.common()->Call(desc), phi); 6230 Node* call = r.AddNode(r.common()->Call(desc), phi);
6193 r.Return(call); 6231 r.Return(call);
6194 6232
6195 CHECK_EQ(33, r.Call(1)); 6233 CHECK_EQ(33, r.Call(1));
6196 CHECK_EQ(44, r.Call(0)); 6234 CHECK_EQ(44, r.Call(0));
6197 } 6235 }
6198 6236
6199 } // namespace compiler 6237 } // namespace compiler
6200 } // namespace internal 6238 } // namespace internal
6201 } // namespace v8 6239 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/x87/instruction-selector-x87.cc ('k') | test/cctest/test-assembler-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698