diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-16 19:46:52 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-16 19:46:52 +0000 | 
| commit | 6b3f41ed88e8e440e11a4fbf20b6600529f80049 (patch) | |
| tree | 928b056f24a634d628c80238dbbf10d41b1a71d5 /lib/Transforms/Utils/VNCoercion.cpp | |
| parent | c46e6a5940c50058e00c0c5f9123fd82e338d29a (diff) | |
Notes
Diffstat (limited to 'lib/Transforms/Utils/VNCoercion.cpp')
| -rw-r--r-- | lib/Transforms/Utils/VNCoercion.cpp | 9 | 
1 files changed, 9 insertions, 0 deletions
| diff --git a/lib/Transforms/Utils/VNCoercion.cpp b/lib/Transforms/Utils/VNCoercion.cpp index 83bd29dbca651..60d9ede2c4871 100644 --- a/lib/Transforms/Utils/VNCoercion.cpp +++ b/lib/Transforms/Utils/VNCoercion.cpp @@ -303,6 +303,15 @@ static T *getStoreValueForLoadHelper(T *SrcVal, unsigned Offset, Type *LoadTy,                                       const DataLayout &DL) {    LLVMContext &Ctx = SrcVal->getType()->getContext(); +  // If two pointers are in the same address space, they have the same size, +  // so we don't need to do any truncation, etc. This avoids introducing +  // ptrtoint instructions for pointers that may be non-integral. +  if (SrcVal->getType()->isPointerTy() && LoadTy->isPointerTy() && +      cast<PointerType>(SrcVal->getType())->getAddressSpace() == +          cast<PointerType>(LoadTy)->getAddressSpace()) { +    return SrcVal; +  } +    uint64_t StoreSize = (DL.getTypeSizeInBits(SrcVal->getType()) + 7) / 8;    uint64_t LoadSize = (DL.getTypeSizeInBits(LoadTy) + 7) / 8;    // Compute which bits of the stored value are being used by the load.  Convert | 
