-
- // If we have a grandfather, we need to do some
- // combination of zig and zag.
- int grandfatherdepth = grandfather->Depth;
-
- setDepthAdd(fatherdepth + grandfatherdepth);
- MinOccurrence = grandfather->MinOccurrence;
- Min = grandfather->Min;
-
- ETOccurrence *greatgrandfather = grandfather->Parent;
-
- if (grandfather->Left == father) {
- if (father->Left == this) {
- // Zig zig
- grandfather->setLeft(father->Right);
- father->setLeft(Right);
- setRight(father);
- father->setRight(grandfather);
-
- father->setDepth(-occdepth);
-
- if (father->Left)
- father->Left->setDepthAdd(occdepth);
-
- grandfather->setDepth(-fatherdepth);
- if (grandfather->Left)
- grandfather->Left->setDepthAdd(fatherdepth);
- } else {
- // Zag zig
- grandfather->setLeft(Right);
- father->setRight(Left);
- setLeft(father);
- setRight(grandfather);
-
- father->setDepth(-occdepth);
- if (father->Right)
- father->Right->setDepthAdd(occdepth);
- grandfather->setDepth(-occdepth - fatherdepth);
- if (grandfather->Left)
- grandfather->Left->setDepthAdd(occdepth + fatherdepth);
- }
- } else {
- if (father->Left == this) {
- // Zig zag
- grandfather->setRight(Left);
- father->setLeft(Right);
- setLeft(grandfather);
- setRight(father);
-
- father->setDepth(-occdepth);
- if (father->Left)
- father->Left->setDepthAdd(occdepth);
- grandfather->setDepth(-occdepth - fatherdepth);
- if (grandfather->Right)
- grandfather->Right->setDepthAdd(occdepth + fatherdepth);
- } else { // Zag Zag
- grandfather->setRight(father->Left);
- father->setRight(Left);
- setLeft(father);
- father->setLeft(grandfather);
-
- father->setDepth(-occdepth);
- if (father->Right)
- father->Right->setDepthAdd(occdepth);
- grandfather->setDepth(-fatherdepth);
- if (grandfather->Right)
- grandfather->Right->setDepthAdd(fatherdepth);
- }
+
+ // If NewBBSucc should not stay in our dominator frontier, remove it.
+ // We remove it unless there is a predecessor of NewBBSucc that we
+ // dominate, but we don't strictly dominate NewBBSucc.
+ bool ShouldRemove = true;
+ if ((BasicBlock*)FI == NewBBSucc || !DT.dominates(FI, NewBBSucc)) {
+ // Okay, we know that PredDom does not strictly dominate NewBBSucc.
+ // Check to see if it dominates any predecessors of NewBBSucc.
+ for (pred_iterator PI = pred_begin(NewBBSucc),
+ E = pred_end(NewBBSucc); PI != E; ++PI)
+ if (DT.dominates(FI, *PI)) {
+ ShouldRemove = false;
+ break;
+ }