[LoopReroll] Don't crash on dead code
[oota-llvm.git] / lib / Transforms / Scalar / LoopRerollPass.cpp
index 852f3ed9d51a6c6ffd1335f32380501cd9d063bc..704299f3041e916c924b97998abf6ffdfb9ef87f 100644 (file)
@@ -511,6 +511,8 @@ void LoopReroll::SimpleLoopReduction::add(Loop *L) {
   // (including the PHI), except for the last value (which is used by the PHI
   // and also outside the loop).
   Instruction *C = Instructions.front();
+  if (C->user_empty())
+    return;
 
   do {
     C = cast<Instruction>(*C->user_begin());