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

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

Issue 1405453003: CTZ instruction implemented as optional operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed a bug when bmi1=false Created 5 years, 2 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/x64/macro-assembler-x64.cc ('k') | no next file » | 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 <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"
11 #include "src/codegen.h" 11 #include "src/codegen.h"
12 #include "test/cctest/cctest.h" 12 #include "test/cctest/cctest.h"
13 #include "test/cctest/compiler/codegen-tester.h" 13 #include "test/cctest/compiler/codegen-tester.h"
14 #include "test/cctest/compiler/value-helper.h" 14 #include "test/cctest/compiler/value-helper.h"
15 15
16 using namespace v8::base; 16 using namespace v8::base;
17 using namespace v8::internal; 17 using namespace v8::internal;
18 using namespace v8::internal::compiler; 18 using namespace v8::internal::compiler;
19 19
20 typedef RawMachineAssembler::Label MLabel; 20 typedef RawMachineAssembler::Label MLabel;
21 21
22 TEST(RunInt32Add) { 22 TEST(RunInt32Add) {
23 RawMachineAssemblerTester<int32_t> m; 23 RawMachineAssemblerTester<int32_t> m;
24 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); 24 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1));
25 m.Return(add); 25 m.Return(add);
26 CHECK_EQ(1, m.Call()); 26 CHECK_EQ(1, m.Call());
27 } 27 }
28 28
29 29
30 void TestWord32Ctz(int32_t value, int32_t expected) {
31 RawMachineAssemblerTester<int32_t> m;
32 if (m.machine()->Word32Ctz().IsSupported()) {
33 Node* ctz =
34 m.AddNode(m.machine()->Word32Ctz().op(), m.Int32Constant(value));
35 m.Return(ctz);
36 CHECK_EQ(expected, m.Call());
37 }
38 }
39
40
41 TEST(RunInt32Ctz) {
42 TestWord32Ctz(0x00000000, 32);
43 TestWord32Ctz(0x80000000, 31);
44 TestWord32Ctz(0x40000000, 30);
45 TestWord32Ctz(0x20000000, 29);
46 TestWord32Ctz(0x10000000, 28);
47 TestWord32Ctz(0xa8000000, 27);
48 TestWord32Ctz(0xf4000000, 26);
49 TestWord32Ctz(0x62000000, 25);
50 TestWord32Ctz(0x91000000, 24);
51 TestWord32Ctz(0xcd800000, 23);
52 TestWord32Ctz(0x09400000, 22);
53 TestWord32Ctz(0xaf200000, 21);
54 TestWord32Ctz(0xac100000, 20);
55 TestWord32Ctz(0xe0b80000, 19);
56 TestWord32Ctz(0x9ce40000, 18);
57 TestWord32Ctz(0xc7920000, 17);
58 TestWord32Ctz(0xb8f10000, 16);
59 TestWord32Ctz(0x3b9f8000, 15);
60 TestWord32Ctz(0xdb4c4000, 14);
61 TestWord32Ctz(0xe9a32000, 13);
62 TestWord32Ctz(0xfca61000, 12);
63 TestWord32Ctz(0x6c8a7800, 11);
64 TestWord32Ctz(0x8ce5a400, 10);
65 TestWord32Ctz(0xcb7d0200, 9);
66 TestWord32Ctz(0xcb4dc100, 8);
67 TestWord32Ctz(0xdfbec580, 7);
68 TestWord32Ctz(0x27a9db40, 6);
69 TestWord32Ctz(0xde3bcb20, 5);
70 TestWord32Ctz(0xd7e8a610, 4);
71 TestWord32Ctz(0x9afdbc88, 3);
72 TestWord32Ctz(0x9afdbc84, 2);
73 TestWord32Ctz(0x9afdbc82, 1);
74 TestWord32Ctz(0x9afdbc81, 0);
75 }
76
77
30 static Node* Int32Input(RawMachineAssemblerTester<int32_t>* m, int index) { 78 static Node* Int32Input(RawMachineAssemblerTester<int32_t>* m, int index) {
31 switch (index) { 79 switch (index) {
32 case 0: 80 case 0:
33 return m->Parameter(0); 81 return m->Parameter(0);
34 case 1: 82 case 1:
35 return m->Parameter(1); 83 return m->Parameter(1);
36 case 2: 84 case 2:
37 return m->Int32Constant(0); 85 return m->Int32Constant(0);
38 case 3: 86 case 3:
39 return m->Int32Constant(1); 87 return m->Int32Constant(1);
(...skipping 5389 matching lines...) Expand 10 before | Expand all | Expand 10 after
5429 c->CalleeSavedRegisters(), // callee saved 5477 c->CalleeSavedRegisters(), // callee saved
5430 c->CalleeSavedFPRegisters(), // callee saved FP 5478 c->CalleeSavedFPRegisters(), // callee saved FP
5431 CallDescriptor::kNoFlags, // flags 5479 CallDescriptor::kNoFlags, // flags
5432 "c-call-as-code"); 5480 "c-call-as-code");
5433 Node* call = r.AddNode(r.common()->Call(desc), phi); 5481 Node* call = r.AddNode(r.common()->Call(desc), phi);
5434 r.Return(call); 5482 r.Return(call);
5435 5483
5436 CHECK_EQ(33, r.Call(1)); 5484 CHECK_EQ(33, r.Call(1));
5437 CHECK_EQ(44, r.Call(0)); 5485 CHECK_EQ(44, r.Call(0));
5438 } 5486 }
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698