Lift the speculation visitor above all the helpers that are targeted at
[oota-llvm.git] / lib / Transforms / Scalar / CorrelatedValuePropagation.cpp
index 9b0aadb0b5b032bbea22b6ed21b190506847dc81..3ec6f3dcc31b0d98f377acd8ce4e63b08b98ab33 100644 (file)
@@ -235,6 +235,11 @@ bool CorrelatedValuePropagation::processSwitch(SwitchInst *SI) {
       // This case never fires - remove it.
       CI.getCaseSuccessor()->removePredecessor(BB);
       SI->removeCase(CI); // Does not invalidate the iterator.
+
+      // The condition can be modified by removePredecessor's PHI simplification
+      // logic.
+      Cond = SI->getCondition();
+
       ++NumDeadCases;
       Changed = true;
     } else if (State == LazyValueInfo::True) {