diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-04-18 16:52:08 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-04-18 16:52:08 +0000 |
| commit | 2a7404a9070edd7cfe877eedbc0f4b1a552e9a74 (patch) | |
| tree | 0898a10616ccda48687e6e378e74f9bd8ca92d25 /llvm | |
| parent | 5a475e7936143a088a4212e61f0d0c1454f19d0a (diff) | |
| download | bcm5719-llvm-2a7404a9070edd7cfe877eedbc0f4b1a552e9a74.tar.gz bcm5719-llvm-2a7404a9070edd7cfe877eedbc0f4b1a552e9a74.zip | |
[InstCombine] Create zero constants on demand.
No functional change intended.
llvm-svn: 235257
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index bd79a2697c1..6b3ba6a7aa2 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -1770,19 +1770,17 @@ Instruction *InstCombiner::visitBitCast(BitCastInst &CI) { // If the source and destination are pointers, and this cast is equivalent // to a getelementptr X, 0, 0, 0... turn it into the appropriate gep. // This can enhance SROA and other transforms that want type-safe pointers. - Constant *ZeroUInt = - Constant::getNullValue(Type::getInt32Ty(CI.getContext())); unsigned NumZeros = 0; while (SrcElTy != DstElTy && isa<CompositeType>(SrcElTy) && !SrcElTy->isPointerTy() && SrcElTy->getNumContainedTypes() /* not "{}" */) { - SrcElTy = cast<CompositeType>(SrcElTy)->getTypeAtIndex(ZeroUInt); + SrcElTy = cast<CompositeType>(SrcElTy)->getTypeAtIndex(0U); ++NumZeros; } // If we found a path from the src to dest, create the getelementptr now. if (SrcElTy == DstElTy) { - SmallVector<Value*, 8> Idxs(NumZeros+1, ZeroUInt); + SmallVector<Value *, 8> Idxs(NumZeros + 1, Builder->getInt32(0)); return GetElementPtrInst::CreateInBounds(Src, Idxs); } } |

