| 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 "src/v8.h" | 5 #include "src/v8.h" |
| 6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
| 7 | 7 |
| 8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
| 9 #include "src/compiler/graph-inl.h" | 9 #include "src/compiler/graph-inl.h" |
| 10 #include "src/compiler/phi-reducer.h" | 10 #include "src/compiler/phi-reducer.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 | 90 |
| 91 TEST(PhiReduce1) { | 91 TEST(PhiReduce1) { |
| 92 PhiReducerTester R; | 92 PhiReducerTester R; |
| 93 Node* zero = R.Int32Constant(0); | 93 Node* zero = R.Int32Constant(0); |
| 94 Node* one = R.Int32Constant(1); | 94 Node* one = R.Int32Constant(1); |
| 95 Node* oneish = R.Float64Constant(1.1); | 95 Node* oneish = R.Float64Constant(1.1); |
| 96 Node* param = R.Parameter(); | 96 Node* param = R.Parameter(); |
| 97 | 97 |
| 98 Node* singles[] = {zero, one, oneish, param}; | 98 Node* singles[] = {zero, one, oneish, param}; |
| 99 for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { | 99 for (size_t i = 0; i < arraysize(singles); i++) { |
| 100 R.CheckReduce(singles[i], R.Phi(singles[i])); | 100 R.CheckReduce(singles[i], R.Phi(singles[i])); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 | 104 |
| 105 TEST(PhiReduce2) { | 105 TEST(PhiReduce2) { |
| 106 PhiReducerTester R; | 106 PhiReducerTester R; |
| 107 Node* zero = R.Int32Constant(0); | 107 Node* zero = R.Int32Constant(0); |
| 108 Node* one = R.Int32Constant(1); | 108 Node* one = R.Int32Constant(1); |
| 109 Node* oneish = R.Float64Constant(1.1); | 109 Node* oneish = R.Float64Constant(1.1); |
| 110 Node* param = R.Parameter(); | 110 Node* param = R.Parameter(); |
| 111 | 111 |
| 112 Node* singles[] = {zero, one, oneish, param}; | 112 Node* singles[] = {zero, one, oneish, param}; |
| 113 for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { | 113 for (size_t i = 0; i < arraysize(singles); i++) { |
| 114 Node* a = singles[i]; | 114 Node* a = singles[i]; |
| 115 R.CheckReduce(a, R.Phi(a, a)); | 115 R.CheckReduce(a, R.Phi(a, a)); |
| 116 } | 116 } |
| 117 | 117 |
| 118 for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { | 118 for (size_t i = 0; i < arraysize(singles); i++) { |
| 119 Node* a = singles[i]; | 119 Node* a = singles[i]; |
| 120 R.CheckReduce(a, R.Phi(R.self, a)); | 120 R.CheckReduce(a, R.Phi(R.self, a)); |
| 121 R.CheckReduce(a, R.Phi(a, R.self)); | 121 R.CheckReduce(a, R.Phi(a, R.self)); |
| 122 } | 122 } |
| 123 | 123 |
| 124 for (size_t i = 1; i < ARRAY_SIZE(singles); i++) { | 124 for (size_t i = 1; i < arraysize(singles); i++) { |
| 125 Node* a = singles[i], *b = singles[0]; | 125 Node* a = singles[i], *b = singles[0]; |
| 126 Node* phi1 = R.Phi(b, a); | 126 Node* phi1 = R.Phi(b, a); |
| 127 R.CheckReduce(phi1, phi1); | 127 R.CheckReduce(phi1, phi1); |
| 128 | 128 |
| 129 Node* phi2 = R.Phi(a, b); | 129 Node* phi2 = R.Phi(a, b); |
| 130 R.CheckReduce(phi2, phi2); | 130 R.CheckReduce(phi2, phi2); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| 135 TEST(PhiReduce3) { | 135 TEST(PhiReduce3) { |
| 136 PhiReducerTester R; | 136 PhiReducerTester R; |
| 137 Node* zero = R.Int32Constant(0); | 137 Node* zero = R.Int32Constant(0); |
| 138 Node* one = R.Int32Constant(1); | 138 Node* one = R.Int32Constant(1); |
| 139 Node* oneish = R.Float64Constant(1.1); | 139 Node* oneish = R.Float64Constant(1.1); |
| 140 Node* param = R.Parameter(); | 140 Node* param = R.Parameter(); |
| 141 | 141 |
| 142 Node* singles[] = {zero, one, oneish, param}; | 142 Node* singles[] = {zero, one, oneish, param}; |
| 143 for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { | 143 for (size_t i = 0; i < arraysize(singles); i++) { |
| 144 Node* a = singles[i]; | 144 Node* a = singles[i]; |
| 145 R.CheckReduce(a, R.Phi(a, a, a)); | 145 R.CheckReduce(a, R.Phi(a, a, a)); |
| 146 } | 146 } |
| 147 | 147 |
| 148 for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { | 148 for (size_t i = 0; i < arraysize(singles); i++) { |
| 149 Node* a = singles[i]; | 149 Node* a = singles[i]; |
| 150 R.CheckReduce(a, R.Phi(R.self, a, a)); | 150 R.CheckReduce(a, R.Phi(R.self, a, a)); |
| 151 R.CheckReduce(a, R.Phi(a, R.self, a)); | 151 R.CheckReduce(a, R.Phi(a, R.self, a)); |
| 152 R.CheckReduce(a, R.Phi(a, a, R.self)); | 152 R.CheckReduce(a, R.Phi(a, a, R.self)); |
| 153 } | 153 } |
| 154 | 154 |
| 155 for (size_t i = 1; i < ARRAY_SIZE(singles); i++) { | 155 for (size_t i = 1; i < arraysize(singles); i++) { |
| 156 Node* a = singles[i], *b = singles[0]; | 156 Node* a = singles[i], *b = singles[0]; |
| 157 Node* phi1 = R.Phi(b, a, a); | 157 Node* phi1 = R.Phi(b, a, a); |
| 158 R.CheckReduce(phi1, phi1); | 158 R.CheckReduce(phi1, phi1); |
| 159 | 159 |
| 160 Node* phi2 = R.Phi(a, b, a); | 160 Node* phi2 = R.Phi(a, b, a); |
| 161 R.CheckReduce(phi2, phi2); | 161 R.CheckReduce(phi2, phi2); |
| 162 | 162 |
| 163 Node* phi3 = R.Phi(a, a, b); | 163 Node* phi3 = R.Phi(a, a, b); |
| 164 R.CheckReduce(phi3, phi3); | 164 R.CheckReduce(phi3, phi3); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 | 168 |
| 169 TEST(PhiReduce4) { | 169 TEST(PhiReduce4) { |
| 170 PhiReducerTester R; | 170 PhiReducerTester R; |
| 171 Node* zero = R.Int32Constant(0); | 171 Node* zero = R.Int32Constant(0); |
| 172 Node* one = R.Int32Constant(1); | 172 Node* one = R.Int32Constant(1); |
| 173 Node* oneish = R.Float64Constant(1.1); | 173 Node* oneish = R.Float64Constant(1.1); |
| 174 Node* param = R.Parameter(); | 174 Node* param = R.Parameter(); |
| 175 | 175 |
| 176 Node* singles[] = {zero, one, oneish, param}; | 176 Node* singles[] = {zero, one, oneish, param}; |
| 177 for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { | 177 for (size_t i = 0; i < arraysize(singles); i++) { |
| 178 Node* a = singles[i]; | 178 Node* a = singles[i]; |
| 179 R.CheckReduce(a, R.Phi(a, a, a, a)); | 179 R.CheckReduce(a, R.Phi(a, a, a, a)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { | 182 for (size_t i = 0; i < arraysize(singles); i++) { |
| 183 Node* a = singles[i]; | 183 Node* a = singles[i]; |
| 184 R.CheckReduce(a, R.Phi(R.self, a, a, a)); | 184 R.CheckReduce(a, R.Phi(R.self, a, a, a)); |
| 185 R.CheckReduce(a, R.Phi(a, R.self, a, a)); | 185 R.CheckReduce(a, R.Phi(a, R.self, a, a)); |
| 186 R.CheckReduce(a, R.Phi(a, a, R.self, a)); | 186 R.CheckReduce(a, R.Phi(a, a, R.self, a)); |
| 187 R.CheckReduce(a, R.Phi(a, a, a, R.self)); | 187 R.CheckReduce(a, R.Phi(a, a, a, R.self)); |
| 188 | 188 |
| 189 R.CheckReduce(a, R.Phi(R.self, R.self, a, a)); | 189 R.CheckReduce(a, R.Phi(R.self, R.self, a, a)); |
| 190 R.CheckReduce(a, R.Phi(a, R.self, R.self, a)); | 190 R.CheckReduce(a, R.Phi(a, R.self, R.self, a)); |
| 191 R.CheckReduce(a, R.Phi(a, a, R.self, R.self)); | 191 R.CheckReduce(a, R.Phi(a, a, R.self, R.self)); |
| 192 R.CheckReduce(a, R.Phi(R.self, a, a, R.self)); | 192 R.CheckReduce(a, R.Phi(R.self, a, a, R.self)); |
| 193 } | 193 } |
| 194 | 194 |
| 195 for (size_t i = 1; i < ARRAY_SIZE(singles); i++) { | 195 for (size_t i = 1; i < arraysize(singles); i++) { |
| 196 Node* a = singles[i], *b = singles[0]; | 196 Node* a = singles[i], *b = singles[0]; |
| 197 Node* phi1 = R.Phi(b, a, a, a); | 197 Node* phi1 = R.Phi(b, a, a, a); |
| 198 R.CheckReduce(phi1, phi1); | 198 R.CheckReduce(phi1, phi1); |
| 199 | 199 |
| 200 Node* phi2 = R.Phi(a, b, a, a); | 200 Node* phi2 = R.Phi(a, b, a, a); |
| 201 R.CheckReduce(phi2, phi2); | 201 R.CheckReduce(phi2, phi2); |
| 202 | 202 |
| 203 Node* phi3 = R.Phi(a, a, b, a); | 203 Node* phi3 = R.Phi(a, a, b, a); |
| 204 R.CheckReduce(phi3, phi3); | 204 R.CheckReduce(phi3, phi3); |
| 205 | 205 |
| 206 Node* phi4 = R.Phi(a, a, a, b); | 206 Node* phi4 = R.Phi(a, a, a, b); |
| 207 R.CheckReduce(phi4, phi4); | 207 R.CheckReduce(phi4, phi4); |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 TEST(PhiReduceShouldIgnoreControlNodes) { | 212 TEST(PhiReduceShouldIgnoreControlNodes) { |
| 213 PhiReducerTester R; | 213 PhiReducerTester R; |
| 214 Node* zero = R.Int32Constant(0); | 214 Node* zero = R.Int32Constant(0); |
| 215 Node* one = R.Int32Constant(1); | 215 Node* one = R.Int32Constant(1); |
| 216 Node* oneish = R.Float64Constant(1.1); | 216 Node* oneish = R.Float64Constant(1.1); |
| 217 Node* param = R.Parameter(); | 217 Node* param = R.Parameter(); |
| 218 | 218 |
| 219 Node* singles[] = {zero, one, oneish, param}; | 219 Node* singles[] = {zero, one, oneish, param}; |
| 220 for (size_t i = 0; i < ARRAY_SIZE(singles); ++i) { | 220 for (size_t i = 0; i < arraysize(singles); ++i) { |
| 221 R.CheckReduce(singles[i], R.PhiWithControl(singles[i], R.dead)); | 221 R.CheckReduce(singles[i], R.PhiWithControl(singles[i], R.dead)); |
| 222 R.CheckReduce(singles[i], R.PhiWithControl(R.self, singles[i], R.dead)); | 222 R.CheckReduce(singles[i], R.PhiWithControl(R.self, singles[i], R.dead)); |
| 223 R.CheckReduce(singles[i], R.PhiWithControl(singles[i], R.self, R.dead)); | 223 R.CheckReduce(singles[i], R.PhiWithControl(singles[i], R.self, R.dead)); |
| 224 } | 224 } |
| 225 } | 225 } |
| OLD | NEW |