| 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 "test/cctest/cctest.h" | 5 #include "test/cctest/cctest.h" |
| 6 #include "test/cctest/compiler/codegen-tester.h" | 6 #include "test/cctest/compiler/codegen-tester.h" |
| 7 #include "test/cctest/compiler/value-helper.h" | 7 #include "test/cctest/compiler/value-helper.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| 11 namespace compiler { | 11 namespace compiler { |
| 12 | 12 |
| 13 static IrOpcode::Value int32cmp_opcodes[] = { | 13 static IrOpcode::Value int32cmp_opcodes[] = { |
| 14 IrOpcode::kWord32Equal, IrOpcode::kInt32LessThan, | 14 IrOpcode::kWord32Equal, IrOpcode::kInt32LessThan, |
| 15 IrOpcode::kInt32LessThanOrEqual, IrOpcode::kUint32LessThan, | 15 IrOpcode::kInt32LessThanOrEqual, IrOpcode::kUint32LessThan, |
| 16 IrOpcode::kUint32LessThanOrEqual}; | 16 IrOpcode::kUint32LessThanOrEqual}; |
| 17 | 17 |
| 18 | 18 |
| 19 TEST(BranchCombineWord32EqualZero_1) { | 19 TEST(BranchCombineWord32EqualZero_1) { |
| 20 // Test combining a branch with x == 0 | 20 // Test combining a branch with x == 0 |
| 21 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 21 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 22 int32_t eq_constant = -1033; | 22 int32_t eq_constant = -1033; |
| 23 int32_t ne_constant = 825118; | 23 int32_t ne_constant = 825118; |
| 24 Node* p0 = m.Parameter(0); | 24 Node* p0 = m.Parameter(0); |
| 25 | 25 |
| 26 RawMachineLabel blocka, blockb; | 26 RawMachineLabel blocka, blockb; |
| 27 m.Branch(m.Word32Equal(p0, m.Int32Constant(0)), &blocka, &blockb); | 27 m.Branch(m.Word32Equal(p0, m.Int32Constant(0)), &blocka, &blockb); |
| 28 m.Bind(&blocka); | 28 m.Bind(&blocka); |
| 29 m.Return(m.Int32Constant(eq_constant)); | 29 m.Return(m.Int32Constant(eq_constant)); |
| 30 m.Bind(&blockb); | 30 m.Bind(&blockb); |
| 31 m.Return(m.Int32Constant(ne_constant)); | 31 m.Return(m.Int32Constant(ne_constant)); |
| 32 | 32 |
| 33 FOR_INT32_INPUTS(i) { | 33 FOR_INT32_INPUTS(i) { |
| 34 int32_t a = *i; | 34 int32_t a = *i; |
| 35 int32_t expect = a == 0 ? eq_constant : ne_constant; | 35 int32_t expect = a == 0 ? eq_constant : ne_constant; |
| 36 CHECK_EQ(expect, m.Call(a)); | 36 CHECK_EQ(expect, m.Call(a)); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 | 40 |
| 41 TEST(BranchCombineWord32EqualZero_chain) { | 41 TEST(BranchCombineWord32EqualZero_chain) { |
| 42 // Test combining a branch with a chain of x == 0 == 0 == 0 ... | 42 // Test combining a branch with a chain of x == 0 == 0 == 0 ... |
| 43 int32_t eq_constant = -1133; | 43 int32_t eq_constant = -1133; |
| 44 int32_t ne_constant = 815118; | 44 int32_t ne_constant = 815118; |
| 45 | 45 |
| 46 for (int k = 0; k < 6; k++) { | 46 for (int k = 0; k < 6; k++) { |
| 47 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 47 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 48 Node* p0 = m.Parameter(0); | 48 Node* p0 = m.Parameter(0); |
| 49 RawMachineLabel blocka, blockb; | 49 RawMachineLabel blocka, blockb; |
| 50 Node* cond = p0; | 50 Node* cond = p0; |
| 51 for (int j = 0; j < k; j++) { | 51 for (int j = 0; j < k; j++) { |
| 52 cond = m.Word32Equal(cond, m.Int32Constant(0)); | 52 cond = m.Word32Equal(cond, m.Int32Constant(0)); |
| 53 } | 53 } |
| 54 m.Branch(cond, &blocka, &blockb); | 54 m.Branch(cond, &blocka, &blockb); |
| 55 m.Bind(&blocka); | 55 m.Bind(&blocka); |
| 56 m.Return(m.Int32Constant(eq_constant)); | 56 m.Return(m.Int32Constant(eq_constant)); |
| 57 m.Bind(&blockb); | 57 m.Bind(&blockb); |
| 58 m.Return(m.Int32Constant(ne_constant)); | 58 m.Return(m.Int32Constant(ne_constant)); |
| 59 | 59 |
| 60 FOR_INT32_INPUTS(i) { | 60 FOR_INT32_INPUTS(i) { |
| 61 int32_t a = *i; | 61 int32_t a = *i; |
| 62 int32_t expect = (k & 1) == 1 ? (a == 0 ? eq_constant : ne_constant) | 62 int32_t expect = (k & 1) == 1 ? (a == 0 ? eq_constant : ne_constant) |
| 63 : (a == 0 ? ne_constant : eq_constant); | 63 : (a == 0 ? ne_constant : eq_constant); |
| 64 CHECK_EQ(expect, m.Call(a)); | 64 CHECK_EQ(expect, m.Call(a)); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 TEST(BranchCombineInt32LessThanZero_1) { | 70 TEST(BranchCombineInt32LessThanZero_1) { |
| 71 // Test combining a branch with x < 0 | 71 // Test combining a branch with x < 0 |
| 72 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 72 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 73 int32_t eq_constant = -1433; | 73 int32_t eq_constant = -1433; |
| 74 int32_t ne_constant = 845118; | 74 int32_t ne_constant = 845118; |
| 75 Node* p0 = m.Parameter(0); | 75 Node* p0 = m.Parameter(0); |
| 76 | 76 |
| 77 RawMachineLabel blocka, blockb; | 77 RawMachineLabel blocka, blockb; |
| 78 m.Branch(m.Int32LessThan(p0, m.Int32Constant(0)), &blocka, &blockb); | 78 m.Branch(m.Int32LessThan(p0, m.Int32Constant(0)), &blocka, &blockb); |
| 79 m.Bind(&blocka); | 79 m.Bind(&blocka); |
| 80 m.Return(m.Int32Constant(eq_constant)); | 80 m.Return(m.Int32Constant(eq_constant)); |
| 81 m.Bind(&blockb); | 81 m.Bind(&blockb); |
| 82 m.Return(m.Int32Constant(ne_constant)); | 82 m.Return(m.Int32Constant(ne_constant)); |
| 83 | 83 |
| 84 FOR_INT32_INPUTS(i) { | 84 FOR_INT32_INPUTS(i) { |
| 85 int32_t a = *i; | 85 int32_t a = *i; |
| 86 int32_t expect = a < 0 ? eq_constant : ne_constant; | 86 int32_t expect = a < 0 ? eq_constant : ne_constant; |
| 87 CHECK_EQ(expect, m.Call(a)); | 87 CHECK_EQ(expect, m.Call(a)); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 | 91 |
| 92 TEST(BranchCombineUint32LessThan100_1) { | 92 TEST(BranchCombineUint32LessThan100_1) { |
| 93 // Test combining a branch with x < 100 | 93 // Test combining a branch with x < 100 |
| 94 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 94 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); |
| 95 int32_t eq_constant = 1471; | 95 int32_t eq_constant = 1471; |
| 96 int32_t ne_constant = 88845718; | 96 int32_t ne_constant = 88845718; |
| 97 Node* p0 = m.Parameter(0); | 97 Node* p0 = m.Parameter(0); |
| 98 | 98 |
| 99 RawMachineLabel blocka, blockb; | 99 RawMachineLabel blocka, blockb; |
| 100 m.Branch(m.Uint32LessThan(p0, m.Int32Constant(100)), &blocka, &blockb); | 100 m.Branch(m.Uint32LessThan(p0, m.Int32Constant(100)), &blocka, &blockb); |
| 101 m.Bind(&blocka); | 101 m.Bind(&blocka); |
| 102 m.Return(m.Int32Constant(eq_constant)); | 102 m.Return(m.Int32Constant(eq_constant)); |
| 103 m.Bind(&blockb); | 103 m.Bind(&blockb); |
| 104 m.Return(m.Int32Constant(ne_constant)); | 104 m.Return(m.Int32Constant(ne_constant)); |
| 105 | 105 |
| 106 FOR_UINT32_INPUTS(i) { | 106 FOR_UINT32_INPUTS(i) { |
| 107 uint32_t a = *i; | 107 uint32_t a = *i; |
| 108 int32_t expect = a < 100 ? eq_constant : ne_constant; | 108 int32_t expect = a < 100 ? eq_constant : ne_constant; |
| 109 CHECK_EQ(expect, m.Call(a)); | 109 CHECK_EQ(expect, m.Call(a)); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 | 113 |
| 114 TEST(BranchCombineUint32LessThanOrEqual100_1) { | 114 TEST(BranchCombineUint32LessThanOrEqual100_1) { |
| 115 // Test combining a branch with x <= 100 | 115 // Test combining a branch with x <= 100 |
| 116 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 116 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); |
| 117 int32_t eq_constant = 1479; | 117 int32_t eq_constant = 1479; |
| 118 int32_t ne_constant = 77845719; | 118 int32_t ne_constant = 77845719; |
| 119 Node* p0 = m.Parameter(0); | 119 Node* p0 = m.Parameter(0); |
| 120 | 120 |
| 121 RawMachineLabel blocka, blockb; | 121 RawMachineLabel blocka, blockb; |
| 122 m.Branch(m.Uint32LessThanOrEqual(p0, m.Int32Constant(100)), &blocka, &blockb); | 122 m.Branch(m.Uint32LessThanOrEqual(p0, m.Int32Constant(100)), &blocka, &blockb); |
| 123 m.Bind(&blocka); | 123 m.Bind(&blocka); |
| 124 m.Return(m.Int32Constant(eq_constant)); | 124 m.Return(m.Int32Constant(eq_constant)); |
| 125 m.Bind(&blockb); | 125 m.Bind(&blockb); |
| 126 m.Return(m.Int32Constant(ne_constant)); | 126 m.Return(m.Int32Constant(ne_constant)); |
| 127 | 127 |
| 128 FOR_UINT32_INPUTS(i) { | 128 FOR_UINT32_INPUTS(i) { |
| 129 uint32_t a = *i; | 129 uint32_t a = *i; |
| 130 int32_t expect = a <= 100 ? eq_constant : ne_constant; | 130 int32_t expect = a <= 100 ? eq_constant : ne_constant; |
| 131 CHECK_EQ(expect, m.Call(a)); | 131 CHECK_EQ(expect, m.Call(a)); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 | 135 |
| 136 TEST(BranchCombineZeroLessThanInt32_1) { | 136 TEST(BranchCombineZeroLessThanInt32_1) { |
| 137 // Test combining a branch with 0 < x | 137 // Test combining a branch with 0 < x |
| 138 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 138 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 139 int32_t eq_constant = -2033; | 139 int32_t eq_constant = -2033; |
| 140 int32_t ne_constant = 225118; | 140 int32_t ne_constant = 225118; |
| 141 Node* p0 = m.Parameter(0); | 141 Node* p0 = m.Parameter(0); |
| 142 | 142 |
| 143 RawMachineLabel blocka, blockb; | 143 RawMachineLabel blocka, blockb; |
| 144 m.Branch(m.Int32LessThan(m.Int32Constant(0), p0), &blocka, &blockb); | 144 m.Branch(m.Int32LessThan(m.Int32Constant(0), p0), &blocka, &blockb); |
| 145 m.Bind(&blocka); | 145 m.Bind(&blocka); |
| 146 m.Return(m.Int32Constant(eq_constant)); | 146 m.Return(m.Int32Constant(eq_constant)); |
| 147 m.Bind(&blockb); | 147 m.Bind(&blockb); |
| 148 m.Return(m.Int32Constant(ne_constant)); | 148 m.Return(m.Int32Constant(ne_constant)); |
| 149 | 149 |
| 150 FOR_INT32_INPUTS(i) { | 150 FOR_INT32_INPUTS(i) { |
| 151 int32_t a = *i; | 151 int32_t a = *i; |
| 152 int32_t expect = 0 < a ? eq_constant : ne_constant; | 152 int32_t expect = 0 < a ? eq_constant : ne_constant; |
| 153 CHECK_EQ(expect, m.Call(a)); | 153 CHECK_EQ(expect, m.Call(a)); |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| 157 | 157 |
| 158 TEST(BranchCombineInt32GreaterThanZero_1) { | 158 TEST(BranchCombineInt32GreaterThanZero_1) { |
| 159 // Test combining a branch with x > 0 | 159 // Test combining a branch with x > 0 |
| 160 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 160 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 161 int32_t eq_constant = -1073; | 161 int32_t eq_constant = -1073; |
| 162 int32_t ne_constant = 825178; | 162 int32_t ne_constant = 825178; |
| 163 Node* p0 = m.Parameter(0); | 163 Node* p0 = m.Parameter(0); |
| 164 | 164 |
| 165 RawMachineLabel blocka, blockb; | 165 RawMachineLabel blocka, blockb; |
| 166 m.Branch(m.Int32GreaterThan(p0, m.Int32Constant(0)), &blocka, &blockb); | 166 m.Branch(m.Int32GreaterThan(p0, m.Int32Constant(0)), &blocka, &blockb); |
| 167 m.Bind(&blocka); | 167 m.Bind(&blocka); |
| 168 m.Return(m.Int32Constant(eq_constant)); | 168 m.Return(m.Int32Constant(eq_constant)); |
| 169 m.Bind(&blockb); | 169 m.Bind(&blockb); |
| 170 m.Return(m.Int32Constant(ne_constant)); | 170 m.Return(m.Int32Constant(ne_constant)); |
| 171 | 171 |
| 172 FOR_INT32_INPUTS(i) { | 172 FOR_INT32_INPUTS(i) { |
| 173 int32_t a = *i; | 173 int32_t a = *i; |
| 174 int32_t expect = a > 0 ? eq_constant : ne_constant; | 174 int32_t expect = a > 0 ? eq_constant : ne_constant; |
| 175 CHECK_EQ(expect, m.Call(a)); | 175 CHECK_EQ(expect, m.Call(a)); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 | 179 |
| 180 TEST(BranchCombineWord32EqualP) { | 180 TEST(BranchCombineWord32EqualP) { |
| 181 // Test combining a branch with an Word32Equal. | 181 // Test combining a branch with an Word32Equal. |
| 182 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); | 182 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(), |
| 183 MachineType::Int32()); |
| 183 int32_t eq_constant = -1035; | 184 int32_t eq_constant = -1035; |
| 184 int32_t ne_constant = 825018; | 185 int32_t ne_constant = 825018; |
| 185 Node* p0 = m.Parameter(0); | 186 Node* p0 = m.Parameter(0); |
| 186 Node* p1 = m.Parameter(1); | 187 Node* p1 = m.Parameter(1); |
| 187 | 188 |
| 188 RawMachineLabel blocka, blockb; | 189 RawMachineLabel blocka, blockb; |
| 189 m.Branch(m.Word32Equal(p0, p1), &blocka, &blockb); | 190 m.Branch(m.Word32Equal(p0, p1), &blocka, &blockb); |
| 190 m.Bind(&blocka); | 191 m.Bind(&blocka); |
| 191 m.Return(m.Int32Constant(eq_constant)); | 192 m.Return(m.Int32Constant(eq_constant)); |
| 192 m.Bind(&blockb); | 193 m.Bind(&blockb); |
| 193 m.Return(m.Int32Constant(ne_constant)); | 194 m.Return(m.Int32Constant(ne_constant)); |
| 194 | 195 |
| 195 FOR_INT32_INPUTS(i) { | 196 FOR_INT32_INPUTS(i) { |
| 196 FOR_INT32_INPUTS(j) { | 197 FOR_INT32_INPUTS(j) { |
| 197 int32_t a = *i; | 198 int32_t a = *i; |
| 198 int32_t b = *j; | 199 int32_t b = *j; |
| 199 int32_t expect = a == b ? eq_constant : ne_constant; | 200 int32_t expect = a == b ? eq_constant : ne_constant; |
| 200 CHECK_EQ(expect, m.Call(a, b)); | 201 CHECK_EQ(expect, m.Call(a, b)); |
| 201 } | 202 } |
| 202 } | 203 } |
| 203 } | 204 } |
| 204 | 205 |
| 205 | 206 |
| 206 TEST(BranchCombineWord32EqualI) { | 207 TEST(BranchCombineWord32EqualI) { |
| 207 int32_t eq_constant = -1135; | 208 int32_t eq_constant = -1135; |
| 208 int32_t ne_constant = 925718; | 209 int32_t ne_constant = 925718; |
| 209 | 210 |
| 210 for (int left = 0; left < 2; left++) { | 211 for (int left = 0; left < 2; left++) { |
| 211 FOR_INT32_INPUTS(i) { | 212 FOR_INT32_INPUTS(i) { |
| 212 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 213 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 213 int32_t a = *i; | 214 int32_t a = *i; |
| 214 | 215 |
| 215 Node* p0 = m.Int32Constant(a); | 216 Node* p0 = m.Int32Constant(a); |
| 216 Node* p1 = m.Parameter(0); | 217 Node* p1 = m.Parameter(0); |
| 217 | 218 |
| 218 RawMachineLabel blocka, blockb; | 219 RawMachineLabel blocka, blockb; |
| 219 if (left == 1) m.Branch(m.Word32Equal(p0, p1), &blocka, &blockb); | 220 if (left == 1) m.Branch(m.Word32Equal(p0, p1), &blocka, &blockb); |
| 220 if (left == 0) m.Branch(m.Word32Equal(p1, p0), &blocka, &blockb); | 221 if (left == 0) m.Branch(m.Word32Equal(p1, p0), &blocka, &blockb); |
| 221 m.Bind(&blocka); | 222 m.Bind(&blocka); |
| 222 m.Return(m.Int32Constant(eq_constant)); | 223 m.Return(m.Int32Constant(eq_constant)); |
| 223 m.Bind(&blockb); | 224 m.Bind(&blockb); |
| 224 m.Return(m.Int32Constant(ne_constant)); | 225 m.Return(m.Int32Constant(ne_constant)); |
| 225 | 226 |
| 226 FOR_INT32_INPUTS(j) { | 227 FOR_INT32_INPUTS(j) { |
| 227 int32_t b = *j; | 228 int32_t b = *j; |
| 228 int32_t expect = a == b ? eq_constant : ne_constant; | 229 int32_t expect = a == b ? eq_constant : ne_constant; |
| 229 CHECK_EQ(expect, m.Call(b)); | 230 CHECK_EQ(expect, m.Call(b)); |
| 230 } | 231 } |
| 231 } | 232 } |
| 232 } | 233 } |
| 233 } | 234 } |
| 234 | 235 |
| 235 | 236 |
| 236 TEST(BranchCombineInt32CmpP) { | 237 TEST(BranchCombineInt32CmpP) { |
| 237 int32_t eq_constant = -1235; | 238 int32_t eq_constant = -1235; |
| 238 int32_t ne_constant = 725018; | 239 int32_t ne_constant = 725018; |
| 239 | 240 |
| 240 for (int op = 0; op < 2; op++) { | 241 for (int op = 0; op < 2; op++) { |
| 241 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); | 242 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(), |
| 243 MachineType::Int32()); |
| 242 Node* p0 = m.Parameter(0); | 244 Node* p0 = m.Parameter(0); |
| 243 Node* p1 = m.Parameter(1); | 245 Node* p1 = m.Parameter(1); |
| 244 | 246 |
| 245 RawMachineLabel blocka, blockb; | 247 RawMachineLabel blocka, blockb; |
| 246 if (op == 0) m.Branch(m.Int32LessThan(p0, p1), &blocka, &blockb); | 248 if (op == 0) m.Branch(m.Int32LessThan(p0, p1), &blocka, &blockb); |
| 247 if (op == 1) m.Branch(m.Int32LessThanOrEqual(p0, p1), &blocka, &blockb); | 249 if (op == 1) m.Branch(m.Int32LessThanOrEqual(p0, p1), &blocka, &blockb); |
| 248 m.Bind(&blocka); | 250 m.Bind(&blocka); |
| 249 m.Return(m.Int32Constant(eq_constant)); | 251 m.Return(m.Int32Constant(eq_constant)); |
| 250 m.Bind(&blockb); | 252 m.Bind(&blockb); |
| 251 m.Return(m.Int32Constant(ne_constant)); | 253 m.Return(m.Int32Constant(ne_constant)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 263 } | 265 } |
| 264 } | 266 } |
| 265 | 267 |
| 266 | 268 |
| 267 TEST(BranchCombineInt32CmpI) { | 269 TEST(BranchCombineInt32CmpI) { |
| 268 int32_t eq_constant = -1175; | 270 int32_t eq_constant = -1175; |
| 269 int32_t ne_constant = 927711; | 271 int32_t ne_constant = 927711; |
| 270 | 272 |
| 271 for (int op = 0; op < 2; op++) { | 273 for (int op = 0; op < 2; op++) { |
| 272 FOR_INT32_INPUTS(i) { | 274 FOR_INT32_INPUTS(i) { |
| 273 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 275 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 274 int32_t a = *i; | 276 int32_t a = *i; |
| 275 Node* p0 = m.Int32Constant(a); | 277 Node* p0 = m.Int32Constant(a); |
| 276 Node* p1 = m.Parameter(0); | 278 Node* p1 = m.Parameter(0); |
| 277 | 279 |
| 278 RawMachineLabel blocka, blockb; | 280 RawMachineLabel blocka, blockb; |
| 279 if (op == 0) m.Branch(m.Int32LessThan(p0, p1), &blocka, &blockb); | 281 if (op == 0) m.Branch(m.Int32LessThan(p0, p1), &blocka, &blockb); |
| 280 if (op == 1) m.Branch(m.Int32LessThanOrEqual(p0, p1), &blocka, &blockb); | 282 if (op == 1) m.Branch(m.Int32LessThanOrEqual(p0, p1), &blocka, &blockb); |
| 281 m.Bind(&blocka); | 283 m.Bind(&blocka); |
| 282 m.Return(m.Int32Constant(eq_constant)); | 284 m.Return(m.Int32Constant(eq_constant)); |
| 283 m.Bind(&blockb); | 285 m.Bind(&blockb); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 double input_b = 0.0; | 422 double input_b = 0.0; |
| 421 | 423 |
| 422 CompareWrapper cmps[] = {CompareWrapper(IrOpcode::kFloat64Equal), | 424 CompareWrapper cmps[] = {CompareWrapper(IrOpcode::kFloat64Equal), |
| 423 CompareWrapper(IrOpcode::kFloat64LessThan), | 425 CompareWrapper(IrOpcode::kFloat64LessThan), |
| 424 CompareWrapper(IrOpcode::kFloat64LessThanOrEqual)}; | 426 CompareWrapper(IrOpcode::kFloat64LessThanOrEqual)}; |
| 425 | 427 |
| 426 for (size_t c = 0; c < arraysize(cmps); c++) { | 428 for (size_t c = 0; c < arraysize(cmps); c++) { |
| 427 CompareWrapper cmp = cmps[c]; | 429 CompareWrapper cmp = cmps[c]; |
| 428 for (int invert = 0; invert < 2; invert++) { | 430 for (int invert = 0; invert < 2; invert++) { |
| 429 RawMachineAssemblerTester<int32_t> m; | 431 RawMachineAssemblerTester<int32_t> m; |
| 430 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); | 432 Node* a = m.LoadFromPointer(&input_a, MachineType::Float64()); |
| 431 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); | 433 Node* b = m.LoadFromPointer(&input_b, MachineType::Float64()); |
| 432 | 434 |
| 433 RawMachineLabel blocka, blockb; | 435 RawMachineLabel blocka, blockb; |
| 434 Node* cond = cmp.MakeNode(&m, a, b); | 436 Node* cond = cmp.MakeNode(&m, a, b); |
| 435 if (invert) cond = m.Word32Equal(cond, m.Int32Constant(0)); | 437 if (invert) cond = m.Word32Equal(cond, m.Int32Constant(0)); |
| 436 m.Branch(cond, &blocka, &blockb); | 438 m.Branch(cond, &blocka, &blockb); |
| 437 m.Bind(&blocka); | 439 m.Bind(&blocka); |
| 438 m.Return(m.Int32Constant(eq_constant)); | 440 m.Return(m.Int32Constant(eq_constant)); |
| 439 m.Bind(&blockb); | 441 m.Bind(&blockb); |
| 440 m.Return(m.Int32Constant(ne_constant)); | 442 m.Return(m.Int32Constant(ne_constant)); |
| 441 | 443 |
| 442 for (size_t i = 0; i < arraysize(inputs); ++i) { | 444 for (size_t i = 0; i < arraysize(inputs); ++i) { |
| 443 for (size_t j = 0; j < arraysize(inputs); ++j) { | 445 for (size_t j = 0; j < arraysize(inputs); ++j) { |
| 444 input_a = inputs[i]; | 446 input_a = inputs[i]; |
| 445 input_b = inputs[j]; | 447 input_b = inputs[j]; |
| 446 int32_t expected = | 448 int32_t expected = |
| 447 invert ? (cmp.Float64Compare(input_a, input_b) ? ne_constant | 449 invert ? (cmp.Float64Compare(input_a, input_b) ? ne_constant |
| 448 : eq_constant) | 450 : eq_constant) |
| 449 : (cmp.Float64Compare(input_a, input_b) ? eq_constant | 451 : (cmp.Float64Compare(input_a, input_b) ? eq_constant |
| 450 : ne_constant); | 452 : ne_constant); |
| 451 CHECK_EQ(expected, m.Call()); | 453 CHECK_EQ(expected, m.Call()); |
| 452 } | 454 } |
| 453 } | 455 } |
| 454 } | 456 } |
| 455 } | 457 } |
| 456 } | 458 } |
| 457 | 459 |
| 458 } // namespace compiler | 460 } // namespace compiler |
| 459 } // namespace internal | 461 } // namespace internal |
| 460 } // namespace v8 | 462 } // namespace v8 |
| OLD | NEW |