InstSimplify: Don't try to replace an extractvalue/insertvalue pair with the original value if types don't match.
Fixes clang selfhost.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139120 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp
index deb7fed..131cc97 100644
--- a/lib/Analysis/InstructionSimplify.cpp
+++ b/lib/Analysis/InstructionSimplify.cpp
@@ -2286,7 +2286,8 @@
// insertvalue x, (extractvalue y, n), n
if (ExtractValueInst *EV = dyn_cast<ExtractValueInst>(Val))
- if (EV->getIndices() == Idxs) {
+ if (EV->getAggregateOperand()->getType() == Agg->getType() &&
+ EV->getIndices() == Idxs) {
// insertvalue undef, (extractvalue y, n), n -> y
if (match(Agg, m_Undef()))
return EV->getAggregateOperand();