diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-10-22 06:44:07 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-10-22 06:44:07 +0000 |
| commit | 7bdc6d5cc22c8e45cbd1c2afec51a7d4c2597a12 (patch) | |
| tree | 45c5146a7c11352f86abfe1d42aee857da36447e /lib/Transforms/Scalar/InstructionCombining.cpp | |
| parent | c352ed0063694702fc056d18bacec36f73761b16 (diff) | |
| download | external_llvm-7bdc6d5cc22c8e45cbd1c2afec51a7d4c2597a12.zip external_llvm-7bdc6d5cc22c8e45cbd1c2afec51a7d4c2597a12.tar.gz external_llvm-7bdc6d5cc22c8e45cbd1c2afec51a7d4c2597a12.tar.bz2 | |
move another load optimization from instcombine -> libanalysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84841 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/InstructionCombining.cpp')
| -rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 62cd532..b41b5d4 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -11364,7 +11364,8 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI, if (Constant *CSrc = dyn_cast<Constant>(CastOp)) if (ASrcTy->getNumElements() != 0) { Value *Idxs[2]; - Idxs[0] = Idxs[1] = Constant::getNullValue(Type::getInt32Ty(*Context)); + Idxs[0] = Constant::getNullValue(Type::getInt32Ty(*Context)); + Idxs[1] = Idxs[0]; CastOp = ConstantExpr::getGetElementPtr(CSrc, Idxs, 2); SrcTy = cast<PointerType>(CastOp->getType()); SrcPTy = SrcTy->getElementType(); @@ -11453,17 +11454,6 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { if (Instruction *Res = InstCombineLoadCast(*this, LI, TD)) return Res; - // If this load comes from anywhere in a constant global, and if the global - // is all undef or zero, we know what it loads. - if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Op->getUnderlyingObject())){ - if (GV->isConstant() && GV->hasDefinitiveInitializer()) { - if (GV->getInitializer()->isNullValue()) - return ReplaceInstUsesWith(LI, Constant::getNullValue(LI.getType())); - else if (isa<UndefValue>(GV->getInitializer())) - return ReplaceInstUsesWith(LI, UndefValue::get(LI.getType())); - } - } - if (Op->hasOneUse()) { // Change select and PHI nodes to select values instead of addresses: this // helps alias analysis out a lot, allows many others simplifications, and |
