diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-30 20:36:46 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-30 20:36:46 +0000 |
commit | 963f4ba8265f17c781e11e10cdc09e4c88bc5cf3 (patch) | |
tree | e8ec76b43da0d1dd0cadce0a83ebebac5f3ce2d0 /lib/Transforms/Scalar | |
parent | 8a67ac525ed874473f0cbe4fc4a02a2606bff7dd (diff) | |
download | external_llvm-963f4ba8265f17c781e11e10cdc09e4c88bc5cf3.zip external_llvm-963f4ba8265f17c781e11e10cdc09e4c88bc5cf3.tar.gz external_llvm-963f4ba8265f17c781e11e10cdc09e4c88bc5cf3.tar.bz2 |
misc cleanup
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80507 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 478068c..a02aa5d 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -10784,8 +10784,7 @@ Instruction *InstCombiner::visitPHINode(PHINode &PN) { Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { Value *PtrOp = GEP.getOperand(0); - // Is it 'getelementptr %P, i32 0' or 'getelementptr %P' - // If so, eliminate the noop. + // Eliminate 'getelementptr %P, i32 0' and 'getelementptr %P', they are noops. if (GEP.getNumOperands() == 1) return ReplaceInstUsesWith(GEP, PtrOp); @@ -10896,15 +10895,15 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { // Handle gep(bitcast x) and gep(gep x, 0, 0, 0). if (Value *X = getBitCastOperand(PtrOp)) { assert(isa<PointerType>(X->getType()) && "Must be cast from pointer"); - + + // Transform: GEP (bitcast [10 x i8]* X to [0 x i8]*), i32 0, ... + // into : GEP [10 x i8]* X, i32 0, ... + // + // Likewise, transform: GEP (bitcast i8* X to [0 x i8]*), i32 0, ... + // into : GEP i8* X, ... + // + // This occurs when the program declares an array extern like "int X[];" if (HasZeroPointerIndex) { - // transform: GEP (bitcast [10 x i8]* X to [0 x i8]*), i32 0, ... - // into : GEP [10 x i8]* X, i32 0, ... - // - // Likewise, transform: GEP (bitcast i8* X to [0 x i8]*), i32 0, ... - // into : GEP i8* X, ... - // - // This occurs when the program declares an array extern like "int X[];" const PointerType *CPTy = cast<PointerType>(PtrOp->getType()); const PointerType *XTy = cast<PointerType>(X->getType()); if (const ArrayType *CATy = @@ -10919,8 +10918,9 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { if (cast<GEPOperator>(&GEP)->isInBounds()) cast<GEPOperator>(NewGEP)->setIsInBounds(true); return NewGEP; - } else if (const ArrayType *XATy = - dyn_cast<ArrayType>(XTy->getElementType())) { + } + + if (const ArrayType *XATy = dyn_cast<ArrayType>(XTy->getElementType())){ // GEP (bitcast [10 x i8]* X to [0 x i8]*), i32 0, ... ? if (CATy->getElementType() == XATy->getElementType()) { // -> GEP [10 x i8]* X, i32 0, ... @@ -11271,7 +11271,7 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { LI.setAlignment(KnownAlign); } - // load (cast X) --> cast (load X) iff safe + // load (cast X) --> cast (load X) iff safe. if (isa<CastInst>(Op)) if (Instruction *Res = InstCombineLoadCast(*this, LI, TD)) return Res; |