summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorJoey Gouly <joey.gouly@gmail.com>2017-06-06 10:17:14 +0000
committerJoey Gouly <joey.gouly@gmail.com>2017-06-06 10:17:14 +0000
commit61eaa63b65e7f0ba6c906d2372ad66c07e9d392c (patch)
treed8966f510c158b225dcac95fc5d0a00b39fb1966 /llvm/lib/Analysis
parent8a2e00e631c24f37abb83b96dadbab8bb66893f6 (diff)
downloadbcm5719-llvm-61eaa63b65e7f0ba6c906d2372ad66c07e9d392c.tar.gz
bcm5719-llvm-61eaa63b65e7f0ba6c906d2372ad66c07e9d392c.zip
[InstSimplify] Constant fold the new GEP in SimplifyGEPInst.
llvm-svn: 304784
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index ea83c83ed0c..aa7993b875c 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -3884,8 +3884,11 @@ static Value *SimplifyGEPInst(Type *SrcTy, ArrayRef<Value *> Ops,
if (!all_of(Ops, [](Value *V) { return isa<Constant>(V); }))
return nullptr;
- return ConstantExpr::getGetElementPtr(SrcTy, cast<Constant>(Ops[0]),
- Ops.slice(1));
+ auto *CE = ConstantExpr::getGetElementPtr(SrcTy, cast<Constant>(Ops[0]),
+ Ops.slice(1));
+ if (auto *CEFolded = ConstantFoldConstant(CE, Q.DL))
+ return CEFolded;
+ return CE;
}
Value *llvm::SimplifyGEPInst(Type *SrcTy, ArrayRef<Value *> Ops,
OpenPOWER on IntegriCloud