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 | 6 |
7 #include "graph-tester.h" | 7 #include "graph-tester.h" |
8 #include "src/compiler/generic-node-inl.h" | 8 #include "src/compiler/generic-node-inl.h" |
9 #include "src/compiler/graph-reducer.h" | 9 #include "src/compiler/graph-reducer.h" |
10 | 10 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 }; | 195 }; |
196 | 196 |
197 | 197 |
198 TEST(ReduceGraphFromEnd1) { | 198 TEST(ReduceGraphFromEnd1) { |
199 GraphTester graph; | 199 GraphTester graph; |
200 | 200 |
201 Node* n1 = graph.NewNode(&OPA0); | 201 Node* n1 = graph.NewNode(&OPA0); |
202 Node* end = graph.NewNode(&OPA1, n1); | 202 Node* end = graph.NewNode(&OPA1, n1); |
203 graph.SetEnd(end); | 203 graph.SetEnd(end); |
204 | 204 |
205 GraphReducer reducer(&graph); | 205 GraphReducer reducer(&graph, graph.zone()); |
206 ReducerRecorder recorder(graph.zone()); | 206 ReducerRecorder recorder(graph.zone()); |
207 reducer.AddReducer(&recorder); | 207 reducer.AddReducer(&recorder); |
208 reducer.ReduceGraph(); | 208 reducer.ReduceGraph(); |
209 recorder.CheckContains(n1); | 209 recorder.CheckContains(n1); |
210 recorder.CheckContains(end); | 210 recorder.CheckContains(end); |
211 } | 211 } |
212 | 212 |
213 | 213 |
214 TEST(ReduceGraphFromEnd2) { | 214 TEST(ReduceGraphFromEnd2) { |
215 GraphTester graph; | 215 GraphTester graph; |
216 | 216 |
217 Node* n1 = graph.NewNode(&OPA0); | 217 Node* n1 = graph.NewNode(&OPA0); |
218 Node* n2 = graph.NewNode(&OPA1, n1); | 218 Node* n2 = graph.NewNode(&OPA1, n1); |
219 Node* n3 = graph.NewNode(&OPA1, n1); | 219 Node* n3 = graph.NewNode(&OPA1, n1); |
220 Node* end = graph.NewNode(&OPA2, n2, n3); | 220 Node* end = graph.NewNode(&OPA2, n2, n3); |
221 graph.SetEnd(end); | 221 graph.SetEnd(end); |
222 | 222 |
223 GraphReducer reducer(&graph); | 223 GraphReducer reducer(&graph, graph.zone()); |
224 ReducerRecorder recorder(graph.zone()); | 224 ReducerRecorder recorder(graph.zone()); |
225 reducer.AddReducer(&recorder); | 225 reducer.AddReducer(&recorder); |
226 reducer.ReduceGraph(); | 226 reducer.ReduceGraph(); |
227 recorder.CheckContains(n1); | 227 recorder.CheckContains(n1); |
228 recorder.CheckContains(n2); | 228 recorder.CheckContains(n2); |
229 recorder.CheckContains(n3); | 229 recorder.CheckContains(n3); |
230 recorder.CheckContains(end); | 230 recorder.CheckContains(end); |
231 } | 231 } |
232 | 232 |
233 | 233 |
234 TEST(ReduceInPlace1) { | 234 TEST(ReduceInPlace1) { |
235 GraphTester graph; | 235 GraphTester graph; |
236 | 236 |
237 Node* n1 = graph.NewNode(&OPA0); | 237 Node* n1 = graph.NewNode(&OPA0); |
238 Node* end = graph.NewNode(&OPA1, n1); | 238 Node* end = graph.NewNode(&OPA1, n1); |
239 graph.SetEnd(end); | 239 graph.SetEnd(end); |
240 | 240 |
241 GraphReducer reducer(&graph); | 241 GraphReducer reducer(&graph, graph.zone()); |
242 InPlaceABReducer r; | 242 InPlaceABReducer r; |
243 reducer.AddReducer(&r); | 243 reducer.AddReducer(&r); |
244 | 244 |
245 // Tests A* => B* with in-place updates. | 245 // Tests A* => B* with in-place updates. |
246 for (int i = 0; i < 3; i++) { | 246 for (int i = 0; i < 3; i++) { |
247 int before = graph.NodeCount(); | 247 int before = graph.NodeCount(); |
248 reducer.ReduceGraph(); | 248 reducer.ReduceGraph(); |
249 CHECK_EQ(before, graph.NodeCount()); | 249 CHECK_EQ(before, graph.NodeCount()); |
250 CHECK_EQ(&OPB0, n1->op()); | 250 CHECK_EQ(&OPB0, n1->op()); |
251 CHECK_EQ(&OPB1, end->op()); | 251 CHECK_EQ(&OPB1, end->op()); |
252 CHECK_EQ(n1, end->InputAt(0)); | 252 CHECK_EQ(n1, end->InputAt(0)); |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
256 | 256 |
257 TEST(ReduceInPlace2) { | 257 TEST(ReduceInPlace2) { |
258 GraphTester graph; | 258 GraphTester graph; |
259 | 259 |
260 Node* n1 = graph.NewNode(&OPA0); | 260 Node* n1 = graph.NewNode(&OPA0); |
261 Node* n2 = graph.NewNode(&OPA1, n1); | 261 Node* n2 = graph.NewNode(&OPA1, n1); |
262 Node* n3 = graph.NewNode(&OPA1, n1); | 262 Node* n3 = graph.NewNode(&OPA1, n1); |
263 Node* end = graph.NewNode(&OPA2, n2, n3); | 263 Node* end = graph.NewNode(&OPA2, n2, n3); |
264 graph.SetEnd(end); | 264 graph.SetEnd(end); |
265 | 265 |
266 GraphReducer reducer(&graph); | 266 GraphReducer reducer(&graph, graph.zone()); |
267 InPlaceABReducer r; | 267 InPlaceABReducer r; |
268 reducer.AddReducer(&r); | 268 reducer.AddReducer(&r); |
269 | 269 |
270 // Tests A* => B* with in-place updates. | 270 // Tests A* => B* with in-place updates. |
271 for (int i = 0; i < 3; i++) { | 271 for (int i = 0; i < 3; i++) { |
272 int before = graph.NodeCount(); | 272 int before = graph.NodeCount(); |
273 reducer.ReduceGraph(); | 273 reducer.ReduceGraph(); |
274 CHECK_EQ(before, graph.NodeCount()); | 274 CHECK_EQ(before, graph.NodeCount()); |
275 CHECK_EQ(&OPB0, n1->op()); | 275 CHECK_EQ(&OPB0, n1->op()); |
276 CHECK_EQ(&OPB1, n2->op()); | 276 CHECK_EQ(&OPB1, n2->op()); |
277 CHECK_EQ(n1, n2->InputAt(0)); | 277 CHECK_EQ(n1, n2->InputAt(0)); |
278 CHECK_EQ(&OPB1, n3->op()); | 278 CHECK_EQ(&OPB1, n3->op()); |
279 CHECK_EQ(n1, n3->InputAt(0)); | 279 CHECK_EQ(n1, n3->InputAt(0)); |
280 CHECK_EQ(&OPB2, end->op()); | 280 CHECK_EQ(&OPB2, end->op()); |
281 CHECK_EQ(n2, end->InputAt(0)); | 281 CHECK_EQ(n2, end->InputAt(0)); |
282 CHECK_EQ(n3, end->InputAt(1)); | 282 CHECK_EQ(n3, end->InputAt(1)); |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
286 | 286 |
287 TEST(ReduceNew1) { | 287 TEST(ReduceNew1) { |
288 GraphTester graph; | 288 GraphTester graph; |
289 | 289 |
290 Node* n1 = graph.NewNode(&OPA0); | 290 Node* n1 = graph.NewNode(&OPA0); |
291 Node* n2 = graph.NewNode(&OPA1, n1); | 291 Node* n2 = graph.NewNode(&OPA1, n1); |
292 Node* n3 = graph.NewNode(&OPA1, n1); | 292 Node* n3 = graph.NewNode(&OPA1, n1); |
293 Node* end = graph.NewNode(&OPA2, n2, n3); | 293 Node* end = graph.NewNode(&OPA2, n2, n3); |
294 graph.SetEnd(end); | 294 graph.SetEnd(end); |
295 | 295 |
296 GraphReducer reducer(&graph); | 296 GraphReducer reducer(&graph, graph.zone()); |
297 NewABReducer r(&graph); | 297 NewABReducer r(&graph); |
298 reducer.AddReducer(&r); | 298 reducer.AddReducer(&r); |
299 | 299 |
300 // Tests A* => B* while creating new nodes. | 300 // Tests A* => B* while creating new nodes. |
301 for (int i = 0; i < 3; i++) { | 301 for (int i = 0; i < 3; i++) { |
302 int before = graph.NodeCount(); | 302 int before = graph.NodeCount(); |
303 reducer.ReduceGraph(); | 303 reducer.ReduceGraph(); |
304 if (i == 0) { | 304 if (i == 0) { |
305 CHECK_NE(before, graph.NodeCount()); | 305 CHECK_NE(before, graph.NodeCount()); |
306 } else { | 306 } else { |
(...skipping 16 matching lines...) Expand all Loading... |
323 } | 323 } |
324 | 324 |
325 | 325 |
326 TEST(Wrapping1) { | 326 TEST(Wrapping1) { |
327 GraphTester graph; | 327 GraphTester graph; |
328 | 328 |
329 Node* end = graph.NewNode(&OPA0); | 329 Node* end = graph.NewNode(&OPA0); |
330 graph.SetEnd(end); | 330 graph.SetEnd(end); |
331 CHECK_EQ(1, graph.NodeCount()); | 331 CHECK_EQ(1, graph.NodeCount()); |
332 | 332 |
333 GraphReducer reducer(&graph); | 333 GraphReducer reducer(&graph, graph.zone()); |
334 A0Wrapper r(&graph); | 334 A0Wrapper r(&graph); |
335 reducer.AddReducer(&r); | 335 reducer.AddReducer(&r); |
336 | 336 |
337 reducer.ReduceGraph(); | 337 reducer.ReduceGraph(); |
338 CHECK_EQ(2, graph.NodeCount()); | 338 CHECK_EQ(2, graph.NodeCount()); |
339 | 339 |
340 Node* nend = graph.end(); | 340 Node* nend = graph.end(); |
341 CHECK_NE(end, nend); | 341 CHECK_NE(end, nend); |
342 CHECK_EQ(&OPB1, nend->op()); | 342 CHECK_EQ(&OPB1, nend->op()); |
343 CHECK_EQ(1, nend->InputCount()); | 343 CHECK_EQ(1, nend->InputCount()); |
344 CHECK_EQ(end, nend->InputAt(0)); | 344 CHECK_EQ(end, nend->InputAt(0)); |
345 } | 345 } |
346 | 346 |
347 | 347 |
348 TEST(Wrapping2) { | 348 TEST(Wrapping2) { |
349 GraphTester graph; | 349 GraphTester graph; |
350 | 350 |
351 Node* end = graph.NewNode(&OPB0); | 351 Node* end = graph.NewNode(&OPB0); |
352 graph.SetEnd(end); | 352 graph.SetEnd(end); |
353 CHECK_EQ(1, graph.NodeCount()); | 353 CHECK_EQ(1, graph.NodeCount()); |
354 | 354 |
355 GraphReducer reducer(&graph); | 355 GraphReducer reducer(&graph, graph.zone()); |
356 B0Wrapper r(&graph); | 356 B0Wrapper r(&graph); |
357 reducer.AddReducer(&r); | 357 reducer.AddReducer(&r); |
358 | 358 |
359 reducer.ReduceGraph(); | 359 reducer.ReduceGraph(); |
360 CHECK_EQ(3, graph.NodeCount()); | 360 CHECK_EQ(3, graph.NodeCount()); |
361 | 361 |
362 Node* nend = graph.end(); | 362 Node* nend = graph.end(); |
363 CHECK_NE(end, nend); | 363 CHECK_NE(end, nend); |
364 CHECK_EQ(&OPC1, nend->op()); | 364 CHECK_EQ(&OPC1, nend->op()); |
365 CHECK_EQ(1, nend->InputCount()); | 365 CHECK_EQ(1, nend->InputCount()); |
366 | 366 |
367 Node* n1 = nend->InputAt(0); | 367 Node* n1 = nend->InputAt(0); |
368 CHECK_NE(end, n1); | 368 CHECK_NE(end, n1); |
369 CHECK_EQ(&OPC1, n1->op()); | 369 CHECK_EQ(&OPC1, n1->op()); |
370 CHECK_EQ(1, n1->InputCount()); | 370 CHECK_EQ(1, n1->InputCount()); |
371 CHECK_EQ(end, n1->InputAt(0)); | 371 CHECK_EQ(end, n1->InputAt(0)); |
372 } | 372 } |
373 | 373 |
374 | 374 |
375 TEST(Forwarding1) { | 375 TEST(Forwarding1) { |
376 GraphTester graph; | 376 GraphTester graph; |
377 | 377 |
378 Node* n1 = graph.NewNode(&OPA0); | 378 Node* n1 = graph.NewNode(&OPA0); |
379 Node* end = graph.NewNode(&OPA1, n1); | 379 Node* end = graph.NewNode(&OPA1, n1); |
380 graph.SetEnd(end); | 380 graph.SetEnd(end); |
381 | 381 |
382 GraphReducer reducer(&graph); | 382 GraphReducer reducer(&graph, graph.zone()); |
383 A1Forwarder r; | 383 A1Forwarder r; |
384 reducer.AddReducer(&r); | 384 reducer.AddReducer(&r); |
385 | 385 |
386 // Tests A1(x) => x | 386 // Tests A1(x) => x |
387 for (int i = 0; i < 3; i++) { | 387 for (int i = 0; i < 3; i++) { |
388 int before = graph.NodeCount(); | 388 int before = graph.NodeCount(); |
389 reducer.ReduceGraph(); | 389 reducer.ReduceGraph(); |
390 CHECK_EQ(before, graph.NodeCount()); | 390 CHECK_EQ(before, graph.NodeCount()); |
391 CHECK_EQ(&OPA0, n1->op()); | 391 CHECK_EQ(&OPA0, n1->op()); |
392 CHECK_EQ(n1, graph.end()); | 392 CHECK_EQ(n1, graph.end()); |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 | 396 |
397 TEST(Forwarding2) { | 397 TEST(Forwarding2) { |
398 GraphTester graph; | 398 GraphTester graph; |
399 | 399 |
400 Node* n1 = graph.NewNode(&OPA0); | 400 Node* n1 = graph.NewNode(&OPA0); |
401 Node* n2 = graph.NewNode(&OPA1, n1); | 401 Node* n2 = graph.NewNode(&OPA1, n1); |
402 Node* n3 = graph.NewNode(&OPA1, n1); | 402 Node* n3 = graph.NewNode(&OPA1, n1); |
403 Node* end = graph.NewNode(&OPA2, n2, n3); | 403 Node* end = graph.NewNode(&OPA2, n2, n3); |
404 graph.SetEnd(end); | 404 graph.SetEnd(end); |
405 | 405 |
406 GraphReducer reducer(&graph); | 406 GraphReducer reducer(&graph, graph.zone()); |
407 A1Forwarder r; | 407 A1Forwarder r; |
408 reducer.AddReducer(&r); | 408 reducer.AddReducer(&r); |
409 | 409 |
410 // Tests reducing A2(A1(x), A1(y)) => A2(x, y). | 410 // Tests reducing A2(A1(x), A1(y)) => A2(x, y). |
411 for (int i = 0; i < 3; i++) { | 411 for (int i = 0; i < 3; i++) { |
412 int before = graph.NodeCount(); | 412 int before = graph.NodeCount(); |
413 reducer.ReduceGraph(); | 413 reducer.ReduceGraph(); |
414 CHECK_EQ(before, graph.NodeCount()); | 414 CHECK_EQ(before, graph.NodeCount()); |
415 CHECK_EQ(&OPA0, n1->op()); | 415 CHECK_EQ(&OPA0, n1->op()); |
416 CHECK_EQ(n1, end->InputAt(0)); | 416 CHECK_EQ(n1, end->InputAt(0)); |
(...skipping 10 matching lines...) Expand all Loading... |
427 for (int i = 0; i < 8; i++) { | 427 for (int i = 0; i < 8; i++) { |
428 GraphTester graph; | 428 GraphTester graph; |
429 | 429 |
430 Node* n1 = graph.NewNode(&OPA0); | 430 Node* n1 = graph.NewNode(&OPA0); |
431 Node* end = n1; | 431 Node* end = n1; |
432 for (int j = 0; j < i; j++) { | 432 for (int j = 0; j < i; j++) { |
433 end = graph.NewNode(&OPA1, end); | 433 end = graph.NewNode(&OPA1, end); |
434 } | 434 } |
435 graph.SetEnd(end); | 435 graph.SetEnd(end); |
436 | 436 |
437 GraphReducer reducer(&graph); | 437 GraphReducer reducer(&graph, graph.zone()); |
438 A1Forwarder r; | 438 A1Forwarder r; |
439 reducer.AddReducer(&r); | 439 reducer.AddReducer(&r); |
440 | 440 |
441 for (int i = 0; i < 3; i++) { | 441 for (int i = 0; i < 3; i++) { |
442 int before = graph.NodeCount(); | 442 int before = graph.NodeCount(); |
443 reducer.ReduceGraph(); | 443 reducer.ReduceGraph(); |
444 CHECK_EQ(before, graph.NodeCount()); | 444 CHECK_EQ(before, graph.NodeCount()); |
445 CHECK_EQ(&OPA0, n1->op()); | 445 CHECK_EQ(&OPA0, n1->op()); |
446 CHECK_EQ(n1, graph.end()); | 446 CHECK_EQ(n1, graph.end()); |
447 } | 447 } |
448 } | 448 } |
449 } | 449 } |
450 | 450 |
451 | 451 |
452 TEST(ReduceForward1) { | 452 TEST(ReduceForward1) { |
453 GraphTester graph; | 453 GraphTester graph; |
454 | 454 |
455 Node* n1 = graph.NewNode(&OPA0); | 455 Node* n1 = graph.NewNode(&OPA0); |
456 Node* n2 = graph.NewNode(&OPA1, n1); | 456 Node* n2 = graph.NewNode(&OPA1, n1); |
457 Node* n3 = graph.NewNode(&OPA1, n1); | 457 Node* n3 = graph.NewNode(&OPA1, n1); |
458 Node* end = graph.NewNode(&OPA2, n2, n3); | 458 Node* end = graph.NewNode(&OPA2, n2, n3); |
459 graph.SetEnd(end); | 459 graph.SetEnd(end); |
460 | 460 |
461 GraphReducer reducer(&graph); | 461 GraphReducer reducer(&graph, graph.zone()); |
462 InPlaceABReducer r; | 462 InPlaceABReducer r; |
463 B1Forwarder f; | 463 B1Forwarder f; |
464 reducer.AddReducer(&r); | 464 reducer.AddReducer(&r); |
465 reducer.AddReducer(&f); | 465 reducer.AddReducer(&f); |
466 | 466 |
467 // Tests first reducing A => B, then B1(x) => x. | 467 // Tests first reducing A => B, then B1(x) => x. |
468 for (int i = 0; i < 3; i++) { | 468 for (int i = 0; i < 3; i++) { |
469 int before = graph.NodeCount(); | 469 int before = graph.NodeCount(); |
470 reducer.ReduceGraph(); | 470 reducer.ReduceGraph(); |
471 CHECK_EQ(before, graph.NodeCount()); | 471 CHECK_EQ(before, graph.NodeCount()); |
(...skipping 22 matching lines...) Expand all Loading... |
494 | 494 |
495 if (i == 0) end = graph.NewNode(&OPA2, n2, n3); | 495 if (i == 0) end = graph.NewNode(&OPA2, n2, n3); |
496 if (i == 1) end = graph.NewNode(&OPA2, n3, n2); | 496 if (i == 1) end = graph.NewNode(&OPA2, n3, n2); |
497 if (i == 2) end = graph.NewNode(&OPA2, n2, n1); | 497 if (i == 2) end = graph.NewNode(&OPA2, n2, n1); |
498 if (i == 3) end = graph.NewNode(&OPA2, n1, n2); | 498 if (i == 3) end = graph.NewNode(&OPA2, n1, n2); |
499 if (i == 4) end = graph.NewNode(&OPA2, n3, n1); | 499 if (i == 4) end = graph.NewNode(&OPA2, n3, n1); |
500 if (i == 5) end = graph.NewNode(&OPA2, n1, n3); | 500 if (i == 5) end = graph.NewNode(&OPA2, n1, n3); |
501 | 501 |
502 graph.SetEnd(end); | 502 graph.SetEnd(end); |
503 | 503 |
504 GraphReducer reducer(&graph); | 504 GraphReducer reducer(&graph, graph.zone()); |
505 reducer.AddReducer(&r); | 505 reducer.AddReducer(&r); |
506 | 506 |
507 int before = graph.NodeCount(); | 507 int before = graph.NodeCount(); |
508 reducer.ReduceGraph(); | 508 reducer.ReduceGraph(); |
509 CHECK_EQ(before, graph.NodeCount()); | 509 CHECK_EQ(before, graph.NodeCount()); |
510 CHECK_EQ(&OPA0, n1->op()); | 510 CHECK_EQ(&OPA0, n1->op()); |
511 CHECK_EQ(&OPA1, n2->op()); | 511 CHECK_EQ(&OPA1, n2->op()); |
512 CHECK_EQ(&OPA1, n3->op()); | 512 CHECK_EQ(&OPA1, n3->op()); |
513 CHECK_EQ(&OPA2, end->op()); | 513 CHECK_EQ(&OPA2, end->op()); |
514 CHECK_EQ(end, graph.end()); | 514 CHECK_EQ(end, graph.end()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 if (p2[z] == -1) { | 553 if (p2[z] == -1) { |
554 if (p == 0) p2[z] = d - 1; | 554 if (p == 0) p2[z] = d - 1; |
555 p--; | 555 p--; |
556 } | 556 } |
557 } | 557 } |
558 n = n / d; | 558 n = n / d; |
559 } | 559 } |
560 | 560 |
561 GenDAG(&graph, p3, p2, p1); | 561 GenDAG(&graph, p3, p2, p1); |
562 | 562 |
563 GraphReducer reducer(&graph); | 563 GraphReducer reducer(&graph, graph.zone()); |
564 AB2Sorter r1; | 564 AB2Sorter r1; |
565 A1Forwarder r2; | 565 A1Forwarder r2; |
566 InPlaceABReducer r3; | 566 InPlaceABReducer r3; |
567 reducer.AddReducer(&r1); | 567 reducer.AddReducer(&r1); |
568 reducer.AddReducer(&r2); | 568 reducer.AddReducer(&r2); |
569 reducer.AddReducer(&r3); | 569 reducer.AddReducer(&r3); |
570 | 570 |
571 reducer.ReduceGraph(); | 571 reducer.ReduceGraph(); |
572 | 572 |
573 Node* end = graph.end(); | 573 Node* end = graph.end(); |
(...skipping 18 matching lines...) Expand all Loading... |
592 TEST(Order) { | 592 TEST(Order) { |
593 // Test that the order of reducers doesn't matter, as they should be | 593 // Test that the order of reducers doesn't matter, as they should be |
594 // rerun for changed nodes. | 594 // rerun for changed nodes. |
595 for (int i = 0; i < 2; i++) { | 595 for (int i = 0; i < 2; i++) { |
596 GraphTester graph; | 596 GraphTester graph; |
597 | 597 |
598 Node* n1 = graph.NewNode(&OPA0); | 598 Node* n1 = graph.NewNode(&OPA0); |
599 Node* end = graph.NewNode(&OPA1, n1); | 599 Node* end = graph.NewNode(&OPA1, n1); |
600 graph.SetEnd(end); | 600 graph.SetEnd(end); |
601 | 601 |
602 GraphReducer reducer(&graph); | 602 GraphReducer reducer(&graph, graph.zone()); |
603 InPlaceABReducer abr; | 603 InPlaceABReducer abr; |
604 InPlaceBCReducer bcr; | 604 InPlaceBCReducer bcr; |
605 if (i == 0) { | 605 if (i == 0) { |
606 reducer.AddReducer(&abr); | 606 reducer.AddReducer(&abr); |
607 reducer.AddReducer(&bcr); | 607 reducer.AddReducer(&bcr); |
608 } else { | 608 } else { |
609 reducer.AddReducer(&bcr); | 609 reducer.AddReducer(&bcr); |
610 reducer.AddReducer(&abr); | 610 reducer.AddReducer(&abr); |
611 } | 611 } |
612 | 612 |
613 // Tests A* => C* with in-place updates. | 613 // Tests A* => C* with in-place updates. |
614 for (int i = 0; i < 3; i++) { | 614 for (int i = 0; i < 3; i++) { |
615 int before = graph.NodeCount(); | 615 int before = graph.NodeCount(); |
616 reducer.ReduceGraph(); | 616 reducer.ReduceGraph(); |
617 CHECK_EQ(before, graph.NodeCount()); | 617 CHECK_EQ(before, graph.NodeCount()); |
618 CHECK_EQ(&OPC0, n1->op()); | 618 CHECK_EQ(&OPC0, n1->op()); |
619 CHECK_EQ(&OPC1, end->op()); | 619 CHECK_EQ(&OPC1, end->op()); |
620 CHECK_EQ(n1, end->InputAt(0)); | 620 CHECK_EQ(n1, end->InputAt(0)); |
621 } | 621 } |
622 } | 622 } |
623 } | 623 } |
OLD | NEW |