aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index fe1ceb7..773a604 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -2316,9 +2316,18 @@ bool CallAnalyzer::visitStore(StoreInst &I) {
}
bool CallAnalyzer::visitExtractValue(ExtractValueInst &I) {
- // Constant folding for extract value is trivial.
- if (simplifyInstruction(I))
- return true;
+ Value *Op = I.getAggregateOperand();
+
+ // Special handling, because we want to simplify extractvalue with a
+ // potential insertvalue from the caller.
+ if (Value *SimpleOp = getSimplifiedValueUnchecked(Op)) {
+ SimplifyQuery SQ(DL);
+ Value *SimpleV = simplifyExtractValueInst(SimpleOp, I.getIndices(), SQ);
+ if (SimpleV) {
+ SimplifiedValues[&I] = SimpleV;
+ return true;
+ }
+ }
// SROA can't look through these, but they may be free.
return Base::visitExtractValue(I);