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

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

Issue 1778893005: [wasm] Int64Lowering of Int64Sub on ia32 and arm. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-add
Patch Set: copy paste mistake Created 4 years, 9 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
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 4179 matching lines...) Expand 10 before | Expand all | Expand 10 after
4190 4190
4191 4191
4192 TEST(RunTruncateFloat64ToFloat32) { 4192 TEST(RunTruncateFloat64ToFloat32) {
4193 BufferedRawMachineAssemblerTester<float> m(MachineType::Float64()); 4193 BufferedRawMachineAssemblerTester<float> m(MachineType::Float64());
4194 4194
4195 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); 4195 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0)));
4196 4196
4197 FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(DoubleToFloat32(*i), m.Call(*i)); } 4197 FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(DoubleToFloat32(*i), m.Call(*i)); }
4198 } 4198 }
4199 4199
4200 int64_t ToInt64(uint32_t low, uint32_t high) { 4200 int64_t ToInt64(uint32_t low, uint32_t high) {
titzer 2016/03/14 09:36:06 You have to make this uint64_t to avoid undefined
ahaas 2016/03/15 11:01:43 I think this function works as intended. To clarif
titzer 2016/03/15 11:05:39 Below, you are doing arithmetic on int64_t values
4201 return (static_cast<int64_t>(high) << 32) | static_cast<int64_t>(low); 4201 return (static_cast<int64_t>(high) << 32) | static_cast<int64_t>(low);
4202 } 4202 }
4203 4203
4204 #if V8_TARGET_ARCH_32_BIT 4204 #if V8_TARGET_ARCH_32_BIT
4205
titzer 2016/03/14 09:36:06 Stray blank line
ahaas 2016/03/15 11:01:43 Removed.
4205 TEST(RunInt32PairAdd) { 4206 TEST(RunInt32PairAdd) {
4206 BufferedRawMachineAssemblerTester<int32_t> m( 4207 BufferedRawMachineAssemblerTester<int32_t> m(
4207 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), 4208 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(),
4208 MachineType::Int32()); 4209 MachineType::Int32());
4209 4210
4210 uint32_t high; 4211 uint32_t high;
4211 uint32_t low; 4212 uint32_t low;
4212 4213
4213 Node* PairAdd = m.Int32PairAdd(m.Parameter(0), m.Parameter(1), m.Parameter(2), 4214 Node* PairAdd = m.Int32PairAdd(m.Parameter(0), m.Parameter(1), m.Parameter(2),
4214 m.Parameter(3)); 4215 m.Parameter(3));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4257 } 4258 }
4258 4259
4259 TEST(RunInt32PairAddWithSharedInput) { 4260 TEST(RunInt32PairAddWithSharedInput) {
4260 TestInt32PairAddWithSharedInput(0, 0, 0, 0); 4261 TestInt32PairAddWithSharedInput(0, 0, 0, 0);
4261 TestInt32PairAddWithSharedInput(1, 0, 0, 0); 4262 TestInt32PairAddWithSharedInput(1, 0, 0, 0);
4262 TestInt32PairAddWithSharedInput(0, 1, 0, 0); 4263 TestInt32PairAddWithSharedInput(0, 1, 0, 0);
4263 TestInt32PairAddWithSharedInput(0, 0, 1, 0); 4264 TestInt32PairAddWithSharedInput(0, 0, 1, 0);
4264 TestInt32PairAddWithSharedInput(0, 0, 0, 1); 4265 TestInt32PairAddWithSharedInput(0, 0, 0, 1);
4265 TestInt32PairAddWithSharedInput(1, 1, 0, 0); 4266 TestInt32PairAddWithSharedInput(1, 1, 0, 0);
4266 } 4267 }
4268
4269 TEST(RunInt32PairSub) {
4270 BufferedRawMachineAssemblerTester<int32_t> m(
4271 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(),
4272 MachineType::Int32());
4273
4274 uint32_t high;
4275 uint32_t low;
4276
4277 Node* PairSub = m.Int32PairSub(m.Parameter(0), m.Parameter(1), m.Parameter(2),
4278 m.Parameter(3));
4279
4280 m.StoreToPointer(&low, MachineRepresentation::kWord32,
titzer 2016/03/14 09:36:06 Why do you need to use memory here?
ahaas 2016/03/15 11:01:43 The BufferedRawMachineAssemblerTester does not sup
4281 m.Projection(0, PairSub));
4282 m.StoreToPointer(&high, MachineRepresentation::kWord32,
4283 m.Projection(1, PairSub));
4284 m.Return(m.Int32Constant(74));
4285
4286 FOR_INT64_INPUTS(i) {
4287 FOR_INT64_INPUTS(j) {
4288 m.Call(static_cast<int32_t>(*i & 0xffffffff),
4289 static_cast<int32_t>(*i >> 32),
4290 static_cast<int32_t>(*j & 0xffffffff),
4291 static_cast<int32_t>(*j >> 32));
4292 CHECK_EQ(*i - *j, ToInt64(low, high));
4293 }
4294 }
4295 }
4296
4297 void TestInt32PairSubWithSharedInput(int a, int b, int c, int d) {
4298 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
4299 MachineType::Uint32());
4300
4301 uint32_t high;
4302 uint32_t low;
4303
4304 Node* PairSub = m.Int32PairSub(m.Parameter(a), m.Parameter(b), m.Parameter(c),
4305 m.Parameter(d));
4306
4307 m.StoreToPointer(&low, MachineRepresentation::kWord32,
4308 m.Projection(0, PairSub));
4309 m.StoreToPointer(&high, MachineRepresentation::kWord32,
4310 m.Projection(1, PairSub));
4311 m.Return(m.Int32Constant(74));
4312
4313 FOR_UINT32_INPUTS(i) {
4314 FOR_UINT32_INPUTS(j) {
4315 m.Call(*i, *j);
4316 uint32_t inputs[] = {*i, *j};
4317 CHECK_EQ(ToInt64(inputs[a], inputs[b]) - ToInt64(inputs[c], inputs[d]),
4318 ToInt64(low, high));
4319 }
4320 }
4321 }
4322
4323 TEST(RunInt32PairSubWithSharedInput) {
4324 TestInt32PairSubWithSharedInput(0, 0, 0, 0);
4325 TestInt32PairSubWithSharedInput(1, 0, 0, 0);
4326 TestInt32PairSubWithSharedInput(0, 1, 0, 0);
4327 TestInt32PairSubWithSharedInput(0, 0, 1, 0);
4328 TestInt32PairSubWithSharedInput(0, 0, 0, 1);
4329 TestInt32PairSubWithSharedInput(1, 1, 0, 0);
4330 }
4267 #endif 4331 #endif
4268 4332
4269 TEST(RunDeadChangeFloat64ToInt32) { 4333 TEST(RunDeadChangeFloat64ToInt32) {
4270 RawMachineAssemblerTester<int32_t> m; 4334 RawMachineAssemblerTester<int32_t> m;
4271 const int magic = 0x88abcda4; 4335 const int magic = 0x88abcda4;
4272 m.ChangeFloat64ToInt32(m.Float64Constant(999.78)); 4336 m.ChangeFloat64ToInt32(m.Float64Constant(999.78));
4273 m.Return(m.Int32Constant(magic)); 4337 m.Return(m.Int32Constant(magic));
4274 CHECK_EQ(magic, m.Call()); 4338 CHECK_EQ(magic, m.Call());
4275 } 4339 }
4276 4340
(...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after
6195 r.Goto(&merge); 6259 r.Goto(&merge);
6196 r.Bind(&merge); 6260 r.Bind(&merge);
6197 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); 6261 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb);
6198 r.Return(phi); 6262 r.Return(phi);
6199 CHECK_EQ(1, r.Call(1)); 6263 CHECK_EQ(1, r.Call(1));
6200 } 6264 }
6201 6265
6202 } // namespace compiler 6266 } // namespace compiler
6203 } // namespace internal 6267 } // namespace internal
6204 } // namespace v8 6268 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698