| OLD | NEW |
| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 122 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
| 123 m.Bind(&blocka); | 123 m.Bind(&blocka); |
| 124 m.Return(m.Int32Constant(0 - constant)); | 124 m.Return(m.Int32Constant(0 - constant)); |
| 125 m.Bind(&blockb); | 125 m.Bind(&blockb); |
| 126 m.Return(m.Int32Constant(constant)); | 126 m.Return(m.Int32Constant(constant)); |
| 127 | 127 |
| 128 CHECK_EQ(constant, m.Call()); | 128 CHECK_EQ(constant, m.Call()); |
| 129 } | 129 } |
| 130 | 130 |
| 131 | 131 |
| 132 TEST(RunRedundantBranch1) { | |
| 133 RawMachineAssemblerTester<int32_t> m; | |
| 134 int constant = 944777; | |
| 135 | |
| 136 MLabel blocka; | |
| 137 m.Branch(m.Int32Constant(0), &blocka, &blocka); | |
| 138 m.Bind(&blocka); | |
| 139 m.Return(m.Int32Constant(constant)); | |
| 140 | |
| 141 CHECK_EQ(constant, m.Call()); | |
| 142 } | |
| 143 | |
| 144 | |
| 145 TEST(RunRedundantBranch2) { | |
| 146 RawMachineAssemblerTester<int32_t> m; | |
| 147 int constant = 966777; | |
| 148 | |
| 149 MLabel blocka, blockb, blockc; | |
| 150 m.Branch(m.Int32Constant(0), &blocka, &blockc); | |
| 151 m.Bind(&blocka); | |
| 152 m.Branch(m.Int32Constant(0), &blockb, &blockb); | |
| 153 m.Bind(&blockc); | |
| 154 m.Goto(&blockb); | |
| 155 m.Bind(&blockb); | |
| 156 m.Return(m.Int32Constant(constant)); | |
| 157 | |
| 158 CHECK_EQ(constant, m.Call()); | |
| 159 } | |
| 160 | |
| 161 | |
| 162 TEST(RunDiamond2) { | 132 TEST(RunDiamond2) { |
| 163 RawMachineAssemblerTester<int32_t> m; | 133 RawMachineAssemblerTester<int32_t> m; |
| 164 | 134 |
| 165 int constant = 995666; | 135 int constant = 995666; |
| 166 | 136 |
| 167 MLabel blocka, blockb, end; | 137 MLabel blocka, blockb, end; |
| 168 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 138 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
| 169 m.Bind(&blocka); | 139 m.Bind(&blocka); |
| 170 m.Goto(&end); | 140 m.Goto(&end); |
| 171 m.Bind(&blockb); | 141 m.Bind(&blockb); |
| (...skipping 4541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4713 m.Float64RoundTiesAway(m.LoadFromPointer(&input, kMachFloat64))); | 4683 m.Float64RoundTiesAway(m.LoadFromPointer(&input, kMachFloat64))); |
| 4714 m.Return(m.Int32Constant(0)); | 4684 m.Return(m.Int32Constant(0)); |
| 4715 for (size_t i = 0; i < arraysize(kValues); ++i) { | 4685 for (size_t i = 0; i < arraysize(kValues); ++i) { |
| 4716 input = kValues[i]; | 4686 input = kValues[i]; |
| 4717 CHECK_EQ(0, m.Call()); | 4687 CHECK_EQ(0, m.Call()); |
| 4718 double expected = round(kValues[i]); | 4688 double expected = round(kValues[i]); |
| 4719 CHECK_EQ(expected, result); | 4689 CHECK_EQ(expected, result); |
| 4720 } | 4690 } |
| 4721 } | 4691 } |
| 4722 #endif // V8_TURBOFAN_TARGET | 4692 #endif // V8_TURBOFAN_TARGET |
| OLD | NEW |