Index: lib/Transforms/Scalar/RewriteStatepointsForGC.cpp =================================================================== --- lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -1813,6 +1813,20 @@ CI->getOperand(0), BaseValue); } + // PHI nodes that have the same incoming values, and belonging to the same + // basic blocks are essentially the same SSA value. + if (PHINode *PhiCurr = dyn_cast(CurrentValue)) + if (PHINode *PhiBase = dyn_cast(BaseValue)) { + int phiNum = PhiCurr->getNumIncomingValues(); + if (phiNum != PhiBase->getNumIncomingValues() || + PhiCurr->getParent() != PhiBase->getParent()) + return false; + for (unsigned i = 0; i < phiNum; i++) + if (PhiCurr->getIncomingValue(i) != PhiBase->getIncomingValue(i)) + return false; + return true; + } + // Not supported instruction in the chain return false; }