Enhance verifyLoop so that it can reliably verify that every block in a loop is reach...
[oota-llvm.git] / lib / VMCore / ConstantFold.cpp
index 458f224575ce80094a1d7ca124ca4c1e6f169e7c..30bae7162cea8fa76e54f1e8f8f4df119f4d3ae0 100644 (file)
@@ -763,12 +763,12 @@ Constant *llvm::ConstantFoldExtractElementInstruction(Constant *Val,
     if (ConstantInt *CIdx = dyn_cast<ConstantInt>(Idx)) {
       uint64_t Index = CIdx->getZExtValue();
       if (Index >= CVal->getNumOperands())
-        // ee({w,x,y,z}, wrong_value) -> w (an arbitrary value).
-        return CVal->getOperand(0);
+        // ee({w,x,y,z}, wrong_value) -> undef
+        return UndefValue::get(cast<VectorType>(Val->getType())->getElementType());
       return CVal->getOperand(CIdx->getZExtValue());
     } else if (isa<UndefValue>(Idx)) {
-      // ee({w,x,y,z}, undef) -> w (an arbitrary value).
-      return CVal->getOperand(0);
+      // ee({w,x,y,z}, undef) -> undef
+      return UndefValue::get(cast<VectorType>(Val->getType())->getElementType());
     }
   }
   return 0;