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

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

Issue 1044793002: [turbofan] Add backend support for float32 operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add MachineOperator unit tests. Created 5 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
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/codegen.h" 10 #include "src/codegen.h"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 414
415 m.Bind(end); 415 m.Bind(end);
416 bt.AddReturn(phi); 416 bt.AddReturn(phi);
417 417
418 CHECK_EQ(0, bt.call(11, 0)); 418 CHECK_EQ(0, bt.call(11, 0));
419 CHECK_EQ(0, bt.call(110, 0)); 419 CHECK_EQ(0, bt.call(110, 0));
420 CHECK_EQ(0, bt.call(197, 0)); 420 CHECK_EQ(0, bt.call(197, 0));
421 } 421 }
422 422
423 423
424 TEST(RunLoopIncrementFloat32) {
425 RawMachineAssemblerTester<int32_t> m;
426
427 // x = -3.0f; while(x < 10f) { x = x + 0.5f; } return (int) (double) x;
428 MLabel header, body;
429 MLabel* end = m.Exit();
430 Node* minus_3 = m.Float32Constant(-3.0f);
431 Node* ten = m.Float32Constant(10.0f);
432
433 m.Goto(&header);
434
435 m.Bind(&header);
436 Node* phi = m.Phi(kMachFloat32, minus_3, ten);
437 m.Branch(m.Float32LessThan(phi, ten), &body, end);
438
439 m.Bind(&body);
440 phi->ReplaceInput(1, m.Float32Add(phi, m.Float32Constant(0.5f)));
441 m.Goto(&header);
442
443 m.Bind(end);
444 m.Return(m.ChangeFloat64ToInt32(m.ChangeFloat32ToFloat64(phi)));
445
446 CHECK_EQ(10, m.Call());
447 }
448
449
424 TEST(RunLoopIncrementFloat64) { 450 TEST(RunLoopIncrementFloat64) {
425 RawMachineAssemblerTester<int32_t> m; 451 RawMachineAssemblerTester<int32_t> m;
426 452
427 // x = -3.0; while(x < 10) { x = x + 0.5; } return (int) x; 453 // x = -3.0; while(x < 10) { x = x + 0.5; } return (int) x;
428 MLabel header, body; 454 MLabel header, body;
429 MLabel* end = m.Exit(); 455 MLabel* end = m.Exit();
430 Node* minus_3 = m.Float64Constant(-3.0); 456 Node* minus_3 = m.Float64Constant(-3.0);
431 Node* ten = m.Float64Constant(10.0); 457 Node* ten = m.Float64Constant(10.0);
432 458
433 m.Goto(&header); 459 m.Goto(&header);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 m.Return(m.LoadFromPointer(pointer, kMachInt32, offset)); 609 m.Return(m.LoadFromPointer(pointer, kMachInt32, offset));
584 610
585 FOR_INT32_INPUTS(j) { 611 FOR_INT32_INPUTS(j) {
586 p1 = *j; 612 p1 = *j;
587 CHECK_EQ(p1, m.Call()); 613 CHECK_EQ(p1, m.Call());
588 } 614 }
589 } 615 }
590 } 616 }
591 617
592 618
619 TEST(RunLoadStoreFloat32Offset) {
620 float p1 = 0.0f; // loads directly from this location.
621 float p2 = 0.0f; // and stores directly into this location.
622
623 FOR_INT32_INPUTS(i) {
624 int32_t magic = 0x2342aabb + *i * 3;
625 RawMachineAssemblerTester<int32_t> m;
626 int32_t offset = *i;
627 byte* from = reinterpret_cast<byte*>(&p1) - offset;
628 byte* to = reinterpret_cast<byte*>(&p2) - offset;
629 // generate load [#base + #index]
630 Node* load =
631 m.Load(kMachFloat32, m.PointerConstant(from), m.IntPtrConstant(offset));
632 m.Store(kMachFloat32, m.PointerConstant(to), m.IntPtrConstant(offset),
633 load);
634 m.Return(m.Int32Constant(magic));
635
636 FOR_FLOAT32_INPUTS(j) {
637 p1 = *j;
638 p2 = *j - 5;
639 CHECK_EQ(magic, m.Call());
640 CheckDoubleEq(p1, p2);
641 }
642 }
643 }
644
645
593 TEST(RunLoadStoreFloat64Offset) { 646 TEST(RunLoadStoreFloat64Offset) {
594 double p1 = 0; // loads directly from this location. 647 double p1 = 0; // loads directly from this location.
595 double p2 = 0; // and stores directly into this location. 648 double p2 = 0; // and stores directly into this location.
596 649
597 FOR_INT32_INPUTS(i) { 650 FOR_INT32_INPUTS(i) {
598 int32_t magic = 0x2342aabb + *i * 3; 651 int32_t magic = 0x2342aabb + *i * 3;
599 RawMachineAssemblerTester<int32_t> m; 652 RawMachineAssemblerTester<int32_t> m;
600 int32_t offset = *i; 653 int32_t offset = *i;
601 byte* from = reinterpret_cast<byte*>(&p1) - offset; 654 byte* from = reinterpret_cast<byte*>(&p1) - offset;
602 byte* to = reinterpret_cast<byte*>(&p2) - offset; 655 byte* to = reinterpret_cast<byte*>(&p2) - offset;
603 // generate load [#base + #index] 656 // generate load [#base + #index]
604 Node* load = 657 Node* load =
605 m.Load(kMachFloat64, m.PointerConstant(from), m.Int32Constant(offset)); 658 m.Load(kMachFloat64, m.PointerConstant(from), m.IntPtrConstant(offset));
606 m.Store(kMachFloat64, m.PointerConstant(to), m.Int32Constant(offset), load); 659 m.Store(kMachFloat64, m.PointerConstant(to), m.IntPtrConstant(offset),
660 load);
607 m.Return(m.Int32Constant(magic)); 661 m.Return(m.Int32Constant(magic));
608 662
609 FOR_FLOAT64_INPUTS(j) { 663 FOR_FLOAT64_INPUTS(j) {
610 p1 = *j; 664 p1 = *j;
611 p2 = *j - 5; 665 p2 = *j - 5;
612 CHECK_EQ(magic, m.Call()); 666 CHECK_EQ(magic, m.Call());
613 CheckDoubleEq(p1, p2); 667 CheckDoubleEq(p1, p2);
614 } 668 }
615 } 669 }
616 } 670 }
(...skipping 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2974 int32_t y = kNumElems - x - 1; 3028 int32_t y = kNumElems - x - 1;
2975 // initialize the buffer with raw data. 3029 // initialize the buffer with raw data.
2976 byte* raw = reinterpret_cast<byte*>(buffer); 3030 byte* raw = reinterpret_cast<byte*>(buffer);
2977 for (size_t i = 0; i < sizeof(buffer); i++) { 3031 for (size_t i = 0; i < sizeof(buffer); i++) {
2978 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); 3032 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA);
2979 } 3033 }
2980 3034
2981 RawMachineAssemblerTester<int32_t> m; 3035 RawMachineAssemblerTester<int32_t> m;
2982 int32_t OK = 0x29000 + x; 3036 int32_t OK = 0x29000 + x;
2983 Node* base = m.PointerConstant(buffer); 3037 Node* base = m.PointerConstant(buffer);
2984 Node* index0 = m.Int32Constant(x * sizeof(buffer[0])); 3038 Node* index0 = m.IntPtrConstant(x * sizeof(buffer[0]));
2985 Node* load = m.Load(rep, base, index0); 3039 Node* load = m.Load(rep, base, index0);
2986 Node* index1 = m.Int32Constant(y * sizeof(buffer[0])); 3040 Node* index1 = m.IntPtrConstant(y * sizeof(buffer[0]));
2987 m.Store(rep, base, index1, load); 3041 m.Store(rep, base, index1, load);
2988 m.Return(m.Int32Constant(OK)); 3042 m.Return(m.Int32Constant(OK));
2989 3043
2990 CHECK(buffer[x] != buffer[y]); 3044 CHECK(buffer[x] != buffer[y]);
2991 CHECK_EQ(OK, m.Call()); 3045 CHECK_EQ(OK, m.Call());
2992 CHECK(buffer[x] == buffer[y]); 3046 CHECK(buffer[x] == buffer[y]);
2993 } 3047 }
2994 } 3048 }
2995 3049
2996 3050
2997 TEST(RunLoadStore) { 3051 TEST(RunLoadStore) {
2998 RunLoadStore<int8_t>(kMachInt8); 3052 RunLoadStore<int8_t>(kMachInt8);
2999 RunLoadStore<uint8_t>(kMachUint8); 3053 RunLoadStore<uint8_t>(kMachUint8);
3000 RunLoadStore<int16_t>(kMachInt16); 3054 RunLoadStore<int16_t>(kMachInt16);
3001 RunLoadStore<uint16_t>(kMachUint16); 3055 RunLoadStore<uint16_t>(kMachUint16);
3002 RunLoadStore<int32_t>(kMachInt32); 3056 RunLoadStore<int32_t>(kMachInt32);
3003 RunLoadStore<uint32_t>(kMachUint32); 3057 RunLoadStore<uint32_t>(kMachUint32);
3004 RunLoadStore<void*>(kMachAnyTagged); 3058 RunLoadStore<void*>(kMachAnyTagged);
3005 RunLoadStore<float>(kMachFloat32); 3059 RunLoadStore<float>(kMachFloat32);
3006 RunLoadStore<double>(kMachFloat64); 3060 RunLoadStore<double>(kMachFloat64);
3007 } 3061 }
3008 3062
3009 3063
3064 TEST(RunFloat32Binop) {
3065 RawMachineAssemblerTester<int32_t> m;
3066 float result;
3067
3068 const Operator* ops[] = {m.machine()->Float32Add(), m.machine()->Float32Sub(),
3069 m.machine()->Float32Mul(), m.machine()->Float32Div(),
3070 NULL};
3071
3072 float inf = std::numeric_limits<float>::infinity();
3073 const Operator* inputs[] = {
3074 m.common()->Float32Constant(0.0f), m.common()->Float32Constant(1.0f),
3075 m.common()->Float32Constant(1.0f), m.common()->Float32Constant(0.0f),
3076 m.common()->Float32Constant(0.0f), m.common()->Float32Constant(-1.0f),
3077 m.common()->Float32Constant(-1.0f), m.common()->Float32Constant(0.0f),
3078 m.common()->Float32Constant(0.22f), m.common()->Float32Constant(-1.22f),
3079 m.common()->Float32Constant(-1.22f), m.common()->Float32Constant(0.22f),
3080 m.common()->Float32Constant(inf), m.common()->Float32Constant(0.22f),
3081 m.common()->Float32Constant(inf), m.common()->Float32Constant(-inf),
3082 NULL};
3083
3084 for (int i = 0; ops[i] != NULL; i++) {
3085 for (int j = 0; inputs[j] != NULL; j += 2) {
3086 RawMachineAssemblerTester<int32_t> m;
3087 Node* a = m.NewNode(inputs[j]);
3088 Node* b = m.NewNode(inputs[j + 1]);
3089 Node* binop = m.NewNode(ops[i], a, b);
3090 Node* base = m.PointerConstant(&result);
3091 Node* zero = m.IntPtrConstant(0);
3092 m.Store(kMachFloat32, base, zero, binop);
3093 m.Return(m.Int32Constant(i + j));
3094 CHECK_EQ(i + j, m.Call());
3095 }
3096 }
3097 }
3098
3099
3010 TEST(RunFloat64Binop) { 3100 TEST(RunFloat64Binop) {
3011 RawMachineAssemblerTester<int32_t> m; 3101 RawMachineAssemblerTester<int32_t> m;
3012 double result; 3102 double result;
3013 3103
3014 const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), 3104 const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(),
3015 m.machine()->Float64Mul(), m.machine()->Float64Div(), 3105 m.machine()->Float64Mul(), m.machine()->Float64Div(),
3016 m.machine()->Float64Mod(), NULL}; 3106 m.machine()->Float64Mod(), NULL};
3017 3107
3018 double inf = V8_INFINITY; 3108 double inf = V8_INFINITY;
3019 const Operator* inputs[] = { 3109 const Operator* inputs[] = {
(...skipping 16 matching lines...) Expand all
3036 Node* base = m.PointerConstant(&result); 3126 Node* base = m.PointerConstant(&result);
3037 Node* zero = m.Int32Constant(0); 3127 Node* zero = m.Int32Constant(0);
3038 m.Store(kMachFloat64, base, zero, binop); 3128 m.Store(kMachFloat64, base, zero, binop);
3039 m.Return(m.Int32Constant(i + j)); 3129 m.Return(m.Int32Constant(i + j));
3040 CHECK_EQ(i + j, m.Call()); 3130 CHECK_EQ(i + j, m.Call());
3041 } 3131 }
3042 } 3132 }
3043 } 3133 }
3044 3134
3045 3135
3136 TEST(RunDeadFloat32Binops) {
3137 RawMachineAssemblerTester<int32_t> m;
3138
3139 const Operator* ops[] = {m.machine()->Float32Add(), m.machine()->Float32Sub(),
3140 m.machine()->Float32Mul(), m.machine()->Float32Div(),
3141 NULL};
3142
3143 for (int i = 0; ops[i] != NULL; i++) {
3144 RawMachineAssemblerTester<int32_t> m;
3145 int constant = 0x53355 + i;
3146 m.NewNode(ops[i], m.Float32Constant(0.1f), m.Float32Constant(1.11f));
3147 m.Return(m.Int32Constant(constant));
3148 CHECK_EQ(constant, m.Call());
3149 }
3150 }
3151
3152
3046 TEST(RunDeadFloat64Binops) { 3153 TEST(RunDeadFloat64Binops) {
3047 RawMachineAssemblerTester<int32_t> m; 3154 RawMachineAssemblerTester<int32_t> m;
3048 3155
3049 const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), 3156 const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(),
3050 m.machine()->Float64Mul(), m.machine()->Float64Div(), 3157 m.machine()->Float64Mul(), m.machine()->Float64Div(),
3051 m.machine()->Float64Mod(), NULL}; 3158 m.machine()->Float64Mod(), NULL};
3052 3159
3053 for (int i = 0; ops[i] != NULL; i++) { 3160 for (int i = 0; ops[i] != NULL; i++) {
3054 RawMachineAssemblerTester<int32_t> m; 3161 RawMachineAssemblerTester<int32_t> m;
3055 int constant = 0x53355 + i; 3162 int constant = 0x53355 + i;
3056 m.NewNode(ops[i], m.Float64Constant(0.1), m.Float64Constant(1.11)); 3163 m.NewNode(ops[i], m.Float64Constant(0.1), m.Float64Constant(1.11));
3057 m.Return(m.Int32Constant(constant)); 3164 m.Return(m.Int32Constant(constant));
3058 CHECK_EQ(constant, m.Call()); 3165 CHECK_EQ(constant, m.Call());
3059 } 3166 }
3060 } 3167 }
3061 3168
3062 3169
3170 TEST(RunFloat32AddP) {
3171 RawMachineAssemblerTester<int32_t> m;
3172 Float32BinopTester bt(&m);
3173
3174 bt.AddReturn(m.Float32Add(bt.param0, bt.param1));
3175
3176 FOR_FLOAT32_INPUTS(pl) {
3177 FOR_FLOAT32_INPUTS(pr) {
3178 float expected = *pl + *pr;
3179 CheckFloatEq(expected, bt.call(*pl, *pr));
3180 }
3181 }
3182 }
3183
3184
3063 TEST(RunFloat64AddP) { 3185 TEST(RunFloat64AddP) {
3064 RawMachineAssemblerTester<int32_t> m; 3186 RawMachineAssemblerTester<int32_t> m;
3065 Float64BinopTester bt(&m); 3187 Float64BinopTester bt(&m);
3066 3188
3067 bt.AddReturn(m.Float64Add(bt.param0, bt.param1)); 3189 bt.AddReturn(m.Float64Add(bt.param0, bt.param1));
3068 3190
3069 FOR_FLOAT64_INPUTS(pl) { 3191 FOR_FLOAT64_INPUTS(pl) {
3070 FOR_FLOAT64_INPUTS(pr) { 3192 FOR_FLOAT64_INPUTS(pr) {
3071 double expected = *pl + *pr; 3193 double expected = *pl + *pr;
3072 CheckDoubleEq(expected, bt.call(*pl, *pr)); 3194 CheckDoubleEq(expected, bt.call(*pl, *pr));
3073 } 3195 }
3074 } 3196 }
3075 } 3197 }
3076 3198
3077 3199
3200 TEST(RunFloat32SubP) {
3201 RawMachineAssemblerTester<int32_t> m;
3202 Float32BinopTester bt(&m);
3203
3204 bt.AddReturn(m.Float32Sub(bt.param0, bt.param1));
3205
3206 FOR_FLOAT32_INPUTS(pl) {
3207 FOR_FLOAT32_INPUTS(pr) {
3208 float expected = *pl - *pr;
3209 CheckFloatEq(expected, bt.call(*pl, *pr));
3210 }
3211 }
3212 }
3213
3214
3078 TEST(RunFloat64SubP) { 3215 TEST(RunFloat64SubP) {
3079 RawMachineAssemblerTester<int32_t> m; 3216 RawMachineAssemblerTester<int32_t> m;
3080 Float64BinopTester bt(&m); 3217 Float64BinopTester bt(&m);
3081 3218
3082 bt.AddReturn(m.Float64Sub(bt.param0, bt.param1)); 3219 bt.AddReturn(m.Float64Sub(bt.param0, bt.param1));
3083 3220
3084 FOR_FLOAT64_INPUTS(pl) { 3221 FOR_FLOAT64_INPUTS(pl) {
3085 FOR_FLOAT64_INPUTS(pr) { 3222 FOR_FLOAT64_INPUTS(pr) {
3086 double expected = *pl - *pr; 3223 double expected = *pl - *pr;
3087 CheckDoubleEq(expected, bt.call(*pl, *pr)); 3224 CheckDoubleEq(expected, bt.call(*pl, *pr));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3123 FOR_FLOAT64_INPUTS(j) { 3260 FOR_FLOAT64_INPUTS(j) {
3124 input = *j; 3261 input = *j;
3125 double expected = input - *i; 3262 double expected = input - *i;
3126 CHECK_EQ(0, m.Call()); 3263 CHECK_EQ(0, m.Call());
3127 CheckDoubleEq(expected, output); 3264 CheckDoubleEq(expected, output);
3128 } 3265 }
3129 } 3266 }
3130 } 3267 }
3131 3268
3132 3269
3270 TEST(RunFloat32MulP) {
3271 RawMachineAssemblerTester<int32_t> m;
3272 Float32BinopTester bt(&m);
3273
3274 bt.AddReturn(m.Float32Mul(bt.param0, bt.param1));
3275
3276 FOR_FLOAT32_INPUTS(pl) {
3277 FOR_FLOAT32_INPUTS(pr) {
3278 float expected = *pl * *pr;
3279 CheckFloatEq(expected, bt.call(*pl, *pr));
3280 }
3281 }
3282 }
3283
3284
3133 TEST(RunFloat64MulP) { 3285 TEST(RunFloat64MulP) {
3134 RawMachineAssemblerTester<int32_t> m; 3286 RawMachineAssemblerTester<int32_t> m;
3135 Float64BinopTester bt(&m); 3287 Float64BinopTester bt(&m);
3136 3288
3137 bt.AddReturn(m.Float64Mul(bt.param0, bt.param1)); 3289 bt.AddReturn(m.Float64Mul(bt.param0, bt.param1));
3138 3290
3139 FOR_FLOAT64_INPUTS(pl) { 3291 FOR_FLOAT64_INPUTS(pl) {
3140 FOR_FLOAT64_INPUTS(pr) { 3292 FOR_FLOAT64_INPUTS(pr) {
3141 double expected = *pl * *pr; 3293 double expected = *pl * *pr;
3142 CheckDoubleEq(expected, bt.call(*pl, *pr)); 3294 CheckDoubleEq(expected, bt.call(*pl, *pr));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
3257 input = *j; 3409 input = *j;
3258 double expected = input * *i; 3410 double expected = input * *i;
3259 CHECK_EQ(0, m.Call()); 3411 CHECK_EQ(0, m.Call());
3260 CheckDoubleEq(expected, output); 3412 CheckDoubleEq(expected, output);
3261 } 3413 }
3262 } 3414 }
3263 } 3415 }
3264 } 3416 }
3265 3417
3266 3418
3419 TEST(RunFloat32DivP) {
3420 RawMachineAssemblerTester<int32_t> m;
3421 Float32BinopTester bt(&m);
3422
3423 bt.AddReturn(m.Float32Div(bt.param0, bt.param1));
3424
3425 FOR_FLOAT32_INPUTS(pl) {
3426 FOR_FLOAT32_INPUTS(pr) {
3427 float expected = *pl / *pr;
3428 CheckFloatEq(expected, bt.call(*pl, *pr));
3429 }
3430 }
3431 }
3432
3433
3267 TEST(RunFloat64DivP) { 3434 TEST(RunFloat64DivP) {
3268 RawMachineAssemblerTester<int32_t> m; 3435 RawMachineAssemblerTester<int32_t> m;
3269 Float64BinopTester bt(&m); 3436 Float64BinopTester bt(&m);
3270 3437
3271 bt.AddReturn(m.Float64Div(bt.param0, bt.param1)); 3438 bt.AddReturn(m.Float64Div(bt.param0, bt.param1));
3272 3439
3273 FOR_FLOAT64_INPUTS(pl) { 3440 FOR_FLOAT64_INPUTS(pl) {
3274 FOR_FLOAT64_INPUTS(pr) { 3441 FOR_FLOAT64_INPUTS(pr) {
3275 double expected = *pl / *pr; 3442 double expected = *pl / *pr;
3276 CheckDoubleEq(expected, bt.call(*pl, *pr)); 3443 CheckDoubleEq(expected, bt.call(*pl, *pr));
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
3612 Node* add = m.Int32Add(phi, m.Int32Constant(1)); 3779 Node* add = m.Int32Add(phi, m.Int32Constant(1));
3613 phi->ReplaceInput(1, add); 3780 phi->ReplaceInput(1, add);
3614 m.Goto(&header); 3781 m.Goto(&header);
3615 m.Bind(&end); 3782 m.Bind(&end);
3616 m.Return(phi); 3783 m.Return(phi);
3617 3784
3618 CHECK_EQ(false_val, m.Call()); 3785 CHECK_EQ(false_val, m.Call());
3619 } 3786 }
3620 3787
3621 3788
3789 TEST(RunFloatDiamond) {
3790 RawMachineAssemblerTester<int32_t> m;
3791
3792 const int magic = 99645;
3793 float buffer = 0.1f;
3794 float constant = 99.99f;
3795
3796 MLabel blocka, blockb, end;
3797 Node* k1 = m.Float32Constant(constant);
3798 Node* k2 = m.Float32Constant(0 - constant);
3799 m.Branch(m.Int32Constant(0), &blocka, &blockb);
3800 m.Bind(&blocka);
3801 m.Goto(&end);
3802 m.Bind(&blockb);
3803 m.Goto(&end);
3804 m.Bind(&end);
3805 Node* phi = m.Phi(kMachFloat32, k2, k1);
3806 m.Store(kMachFloat32, m.PointerConstant(&buffer), m.IntPtrConstant(0), phi);
3807 m.Return(m.Int32Constant(magic));
3808
3809 CHECK_EQ(magic, m.Call());
3810 CHECK(constant == buffer);
3811 }
3812
3813
3622 TEST(RunDoubleDiamond) { 3814 TEST(RunDoubleDiamond) {
3623 RawMachineAssemblerTester<int32_t> m; 3815 RawMachineAssemblerTester<int32_t> m;
3624 3816
3625 const int magic = 99645; 3817 const int magic = 99645;
3626 double buffer = 0.1; 3818 double buffer = 0.1;
3627 double constant = 99.99; 3819 double constant = 99.99;
3628 3820
3629 MLabel blocka, blockb, end; 3821 MLabel blocka, blockb, end;
3630 Node* k1 = m.Float64Constant(constant); 3822 Node* k1 = m.Float64Constant(constant);
3631 Node* k2 = m.Float64Constant(0 - constant); 3823 Node* k2 = m.Float64Constant(0 - constant);
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
4877 m.Return(m.Int32Constant(0)); 5069 m.Return(m.Int32Constant(0));
4878 for (size_t i = 0; i < arraysize(kValues); ++i) { 5070 for (size_t i = 0; i < arraysize(kValues); ++i) {
4879 input = kValues[i]; 5071 input = kValues[i];
4880 CHECK_EQ(0, m.Call()); 5072 CHECK_EQ(0, m.Call());
4881 double expected = round(kValues[i]); 5073 double expected = round(kValues[i]);
4882 CHECK_EQ(expected, result); 5074 CHECK_EQ(expected, result);
4883 } 5075 }
4884 } 5076 }
4885 5077
4886 #endif // V8_TURBOFAN_TARGET 5078 #endif // V8_TURBOFAN_TARGET
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698