Changeset 820
- Timestamp:
- 12/27/10 06:48:36 (14 years ago)
- Files:
-
- branches/dmd-1.x/src/backend/blockopt.c (modified) (1 diff)
- trunk/src/backend/blockopt.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/backend/blockopt.c
r728 r820 580 580 block_appendexp(curblock, e); 581 581 curblock->BC = BCretexp; // put a return at the end 582 582 } 583 583 else 584 584 curblock->BC = BCret; // put a return at the end 585 585 curblock = NULL; // undefined from now on 586 586 block_last = NULL; 587 587 } 588 588 589 589 590 590 /****************************** 591 591 * Perform branch optimization on basic blocks. 592 592 */ 593 593 594 594 void blockopt(int iter) 595 595 { block *b; 596 596 int count; 597 597 598 598 if (OPTIMIZER) 599 599 { 600 int iterationLimit = 200; 601 if (iterationLimit < numblks) 602 iterationLimit = numblks; 600 603 count = 0; 601 604 do 602 605 { 603 606 //printf("changes = %d, count = %d, dfotop = %d\n",changes,count,dfotop); 604 607 #if MARS 605 608 util_progress(); 606 609 #else 607 610 if (controlc_saw) 608 611 util_exit(EXIT_BREAK); 609 612 #endif 610 613 changes = 0; 611 614 bropt(); // branch optimization 612 615 brrear(); // branch rearrangement 613 616 blident(); // combine identical blocks 614 617 blreturn(); // split out return blocks 615 618 bltailmerge(); // do tail merging 616 619 brtailrecursion(); // do tail recursion 617 620 brcombine(); // convert graph to expressions 618 621 if (iter >= 2) 619 622 brmin(); // minimize branching 620 623 do 621 624 { 622 625 compdfo(); /* compute depth first order (DFO) */ 623 626 elimblks(); /* remove blocks not in DFO */ 624 assert(count < 200);627 assert(count < iterationLimit); 625 628 count++; 626 629 } while (mergeblks()); /* merge together blocks */ 627 630 } while (changes); 628 631 #ifdef DEBUG 629 632 if (debugw) 630 633 for (b = startblock; b; b = b->Bnext) 631 634 WRblock(b); 632 635 #endif 633 636 } 634 637 else 635 638 { 636 639 /* canonicalize the trees */ 637 640 for (b = startblock; b; b = b->Bnext) 638 641 { 639 642 #ifdef DEBUG 640 643 if (debugb) 641 644 WRblock(b); 642 645 #endif 643 646 if (b->Belem) 644 647 { b->Belem = doptelem(b->Belem,bc_goal[b->BC] | GOALstruct); trunk/src/backend/blockopt.c
r728 r820 580 580 block_appendexp(curblock, e); 581 581 curblock->BC = BCretexp; // put a return at the end 582 582 } 583 583 else 584 584 curblock->BC = BCret; // put a return at the end 585 585 curblock = NULL; // undefined from now on 586 586 block_last = NULL; 587 587 } 588 588 589 589 590 590 /****************************** 591 591 * Perform branch optimization on basic blocks. 592 592 */ 593 593 594 594 void blockopt(int iter) 595 595 { block *b; 596 596 int count; 597 597 598 598 if (OPTIMIZER) 599 599 { 600 int iterationLimit = 200; 601 if (iterationLimit < numblks) 602 iterationLimit = numblks; 600 603 count = 0; 601 604 do 602 605 { 603 606 //printf("changes = %d, count = %d, dfotop = %d\n",changes,count,dfotop); 604 607 #if MARS 605 608 util_progress(); 606 609 #else 607 610 if (controlc_saw) 608 611 util_exit(EXIT_BREAK); 609 612 #endif 610 613 changes = 0; 611 614 bropt(); // branch optimization 612 615 brrear(); // branch rearrangement 613 616 blident(); // combine identical blocks 614 617 blreturn(); // split out return blocks 615 618 bltailmerge(); // do tail merging 616 619 brtailrecursion(); // do tail recursion 617 620 brcombine(); // convert graph to expressions 618 621 if (iter >= 2) 619 622 brmin(); // minimize branching 620 623 do 621 624 { 622 625 compdfo(); /* compute depth first order (DFO) */ 623 626 elimblks(); /* remove blocks not in DFO */ 624 assert(count < 200);627 assert(count < iterationLimit); 625 628 count++; 626 629 } while (mergeblks()); /* merge together blocks */ 627 630 } while (changes); 628 631 #ifdef DEBUG 629 632 if (debugw) 630 633 for (b = startblock; b; b = b->Bnext) 631 634 WRblock(b); 632 635 #endif 633 636 } 634 637 else 635 638 { 636 639 /* canonicalize the trees */ 637 640 for (b = startblock; b; b = b->Bnext) 638 641 { 639 642 #ifdef DEBUG 640 643 if (debugb) 641 644 WRblock(b); 642 645 #endif 643 646 if (b->Belem) 644 647 { b->Belem = doptelem(b->Belem,bc_goal[b->BC] | GOALstruct);
