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

Side by Side Diff: test/cctest/wasm/test-run-wasm.cc

Issue 1843983002: [wasm] Fixed float-to-int conversion tests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« no previous file with comments | « src/compiler/x87/instruction-selector-x87.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 <stdint.h> 5 #include <stdint.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "src/wasm/wasm-macro-gen.h" 9 #include "src/wasm/wasm-macro-gen.h"
10 10
(...skipping 2681 matching lines...) Expand 10 before | Expand all | Expand 10 after
2692 { 2692 {
2693 WasmRunner<double> r; 2693 WasmRunner<double> r;
2694 BUILD(r, WASM_F64_MAX(WASM_F64(45.73), 2694 BUILD(r, WASM_F64_MAX(WASM_F64(45.73),
2695 WASM_F64(bit_cast<double>(0x7ff000000000f1e2)))); 2695 WASM_F64(bit_cast<double>(0x7ff000000000f1e2))));
2696 CHECK_EQ(0x7ff800000000f1e2, bit_cast<uint64_t>(r.Call())); 2696 CHECK_EQ(0x7ff800000000f1e2, bit_cast<uint64_t>(r.Call()));
2697 } 2697 }
2698 } 2698 }
2699 2699
2700 #endif 2700 #endif
2701 2701
2702 // TODO(titzer): Fix and re-enable.
2703 #if 0
2704 TEST(Run_Wasm_I32SConvertF32) { 2702 TEST(Run_Wasm_I32SConvertF32) {
2705 WasmRunner<int32_t> r(MachineType::Float32()); 2703 WasmRunner<int32_t> r(MachineType::Float32());
2706 BUILD(r, WASM_I32_SCONVERT_F32(WASM_GET_LOCAL(0))); 2704 BUILD(r, WASM_I32_SCONVERT_F32(WASM_GET_LOCAL(0)));
2707 2705
2708 FOR_FLOAT32_INPUTS(i) { 2706 FOR_FLOAT32_INPUTS(i) {
2709 if (*i < static_cast<float>(INT32_MAX) && 2707 if (*i < static_cast<float>(INT32_MAX) &&
2710 *i >= static_cast<float>(INT32_MIN)) { 2708 *i >= static_cast<float>(INT32_MIN)) {
2711 CHECK_EQ(static_cast<int32_t>(*i), r.Call(*i)); 2709 CHECK_EQ(static_cast<int32_t>(*i), r.Call(*i));
2712 } else { 2710 } else {
2713 CHECK_TRAP32(r.Call(*i)); 2711 CHECK_TRAP32(r.Call(*i));
2714 } 2712 }
2715 } 2713 }
2716 } 2714 }
2717 2715
2718 2716
2719 TEST(Run_Wasm_I32SConvertF64) { 2717 TEST(Run_Wasm_I32SConvertF64) {
2720 WasmRunner<int32_t> r(MachineType::Float64()); 2718 WasmRunner<int32_t> r(MachineType::Float64());
2721 BUILD(r, WASM_I32_SCONVERT_F64(WASM_GET_LOCAL(0))); 2719 BUILD(r, WASM_I32_SCONVERT_F64(WASM_GET_LOCAL(0)));
2722 2720
2723 FOR_FLOAT64_INPUTS(i) { 2721 FOR_FLOAT64_INPUTS(i) {
2724 if (*i < static_cast<double>(INT32_MAX) && 2722 if (*i < (static_cast<double>(INT32_MAX) + 1.0) &&
2725 *i >= static_cast<double>(INT32_MIN)) { 2723 *i > (static_cast<double>(INT32_MIN) - 1.0)) {
2726 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); 2724 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i));
2727 } else { 2725 } else {
2728 CHECK_TRAP32(r.Call(*i)); 2726 CHECK_TRAP32(r.Call(*i));
2729 } 2727 }
2730 } 2728 }
2731 } 2729 }
2732 2730
2733 2731
2734 TEST(Run_Wasm_I32UConvertF32) { 2732 TEST(Run_Wasm_I32UConvertF32) {
2735 WasmRunner<uint32_t> r(MachineType::Float32()); 2733 WasmRunner<uint32_t> r(MachineType::Float32());
2736 BUILD(r, WASM_I32_UCONVERT_F32(WASM_GET_LOCAL(0))); 2734 BUILD(r, WASM_I32_UCONVERT_F32(WASM_GET_LOCAL(0)));
2737 2735
2738 FOR_FLOAT32_INPUTS(i) { 2736 FOR_FLOAT32_INPUTS(i) {
2739 if (*i < static_cast<float>(UINT32_MAX) && *i > -1) { 2737 if (*i < (static_cast<float>(UINT32_MAX) + 1.0) && *i > -1) {
2740 CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i)); 2738 CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i));
2741 } else { 2739 } else {
2742 CHECK_TRAP32(r.Call(*i)); 2740 CHECK_TRAP32(r.Call(*i));
2743 } 2741 }
2744 } 2742 }
2745 } 2743 }
2746 2744
2747 2745
2748 TEST(Run_Wasm_I32UConvertF64) { 2746 TEST(Run_Wasm_I32UConvertF64) {
2749 WasmRunner<uint32_t> r(MachineType::Float64()); 2747 WasmRunner<uint32_t> r(MachineType::Float64());
2750 BUILD(r, WASM_I32_UCONVERT_F64(WASM_GET_LOCAL(0))); 2748 BUILD(r, WASM_I32_UCONVERT_F64(WASM_GET_LOCAL(0)));
2751 2749
2752 FOR_FLOAT64_INPUTS(i) { 2750 FOR_FLOAT64_INPUTS(i) {
2753 if (*i < static_cast<float>(UINT32_MAX) && *i > -1) { 2751 if (*i < (static_cast<float>(UINT32_MAX) + 1.0) && *i > -1) {
2754 CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i)); 2752 CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i));
2755 } else { 2753 } else {
2756 CHECK_TRAP32(r.Call(*i)); 2754 CHECK_TRAP32(r.Call(*i));
2757 } 2755 }
2758 } 2756 }
2759 } 2757 }
2760 #endif
2761
2762 2758
2763 TEST(Run_Wasm_F64CopySign) { 2759 TEST(Run_Wasm_F64CopySign) {
2764 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64()); 2760 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64());
2765 BUILD(r, WASM_F64_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2761 BUILD(r, WASM_F64_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2766 2762
2767 FOR_FLOAT64_INPUTS(i) { 2763 FOR_FLOAT64_INPUTS(i) {
2768 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(copysign(*i, *j), r.Call(*i, *j)); } 2764 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(copysign(*i, *j), r.Call(*i, *j)); }
2769 } 2765 }
2770 } 2766 }
2771 2767
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2813 2809
2814 #if WASM_64 2810 #if WASM_64
2815 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } 2811 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); }
2816 #endif 2812 #endif
2817 2813
2818 2814
2819 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } 2815 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); }
2820 2816
2821 2817
2822 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } 2818 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); }
OLDNEW
« no previous file with comments | « src/compiler/x87/instruction-selector-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698