summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2014-10-21 23:49:52 +0000
committerHans Wennborg <hans@hanshq.net>2014-10-21 23:49:52 +0000
commit0b39fc0d16013404f86c9a026ff5535aac18c057 (patch)
treebec050763f788c8f8d96065dedace070a1e4cca5 /llvm/lib
parent9133f8c76d27c350bfc625319558f2f9cd2f8c03 (diff)
downloadbcm5719-llvm-0b39fc0d16013404f86c9a026ff5535aac18c057.tar.gz
bcm5719-llvm-0b39fc0d16013404f86c9a026ff5535aac18c057.zip
Revert "Teach the load analysis to allow finding available values which require" (r220277)
This seems to have caused PR21330. llvm-svn: 220349
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/Loads.cpp14
-rw-r--r--llvm/lib/IR/Instructions.cpp23
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp3
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp8
4 files changed, 9 insertions, 39 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index 5042eb9777a..bb0d60e263e 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -176,13 +176,8 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
Type *AccessTy = cast<PointerType>(Ptr->getType())->getElementType();
- // Try to get the DataLayout for this module. This may be null, in which case
- // the optimizations will be limited.
- const DataLayout *DL = ScanBB->getDataLayout();
-
- // Try to get the store size for the type.
- uint64_t AccessSize = DL ? DL->getTypeStoreSize(AccessTy)
- : AA ? AA->getTypeStoreSize(AccessTy) : 0;
+ // If we're using alias analysis to disambiguate get the size of *Ptr.
+ uint64_t AccessSize = AA ? AA->getTypeStoreSize(AccessTy) : 0;
Value *StrippedPtr = Ptr->stripPointerCasts();
@@ -207,7 +202,7 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
if (LoadInst *LI = dyn_cast<LoadInst>(Inst))
if (AreEquivalentAddressValues(
LI->getPointerOperand()->stripPointerCasts(), StrippedPtr) &&
- CastInst::isBitOrNoopPointerCastable(LI->getType(), AccessTy, DL)) {
+ CastInst::isBitCastable(LI->getType(), AccessTy)) {
if (AATags)
LI->getAAMetadata(*AATags);
return LI;
@@ -219,8 +214,7 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
// (This is true even if the store is volatile or atomic, although
// those cases are unlikely.)
if (AreEquivalentAddressValues(StorePtr, StrippedPtr) &&
- CastInst::isBitOrNoopPointerCastable(SI->getValueOperand()->getType(),
- AccessTy, DL)) {
+ CastInst::isBitCastable(SI->getValueOperand()->getType(), AccessTy)) {
if (AATags)
SI->getAAMetadata(*AATags);
return SI->getOperand(0);
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 9da0eb4a0d6..1497aa885c5 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -2559,17 +2559,6 @@ CastInst *CastInst::CreatePointerBitCastOrAddrSpaceCast(
return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
}
-CastInst *CastInst::CreateBitOrPointerCast(Value *S, Type *Ty,
- const Twine &Name,
- Instruction *InsertBefore) {
- if (S->getType()->isPointerTy() && Ty->isIntegerTy())
- return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);
- if (S->getType()->isIntegerTy() && Ty->isPointerTy())
- return Create(Instruction::IntToPtr, S, Ty, Name, InsertBefore);
-
- return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
-}
-
CastInst *CastInst::CreateIntegerCast(Value *C, Type *Ty,
bool isSigned, const Twine &Name,
Instruction *InsertBefore) {
@@ -2727,18 +2716,6 @@ bool CastInst::isBitCastable(Type *SrcTy, Type *DestTy) {
return true;
}
-bool CastInst::isBitOrNoopPointerCastable(Type *SrcTy, Type *DestTy,
- const DataLayout *DL) {
- if (auto *PtrTy = dyn_cast<PointerType>(SrcTy))
- if (auto *IntTy = dyn_cast<IntegerType>(DestTy))
- return DL && IntTy->getBitWidth() >= DL->getPointerTypeSizeInBits(PtrTy);
- if (auto *PtrTy = dyn_cast<PointerType>(DestTy))
- if (auto *IntTy = dyn_cast<IntegerType>(SrcTy))
- return DL && IntTy->getBitWidth() >= DL->getPointerTypeSizeInBits(PtrTy);
-
- return isBitCastable(SrcTy, DestTy);
-}
-
// Provide a way to get a "cast" where the cast opcode is inferred from the
// types and size of the operand. This, basically, is a parallel of the
// logic in the castIsValid function below. This axiom should hold:
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index c0df914cb66..f3ac44cbd6b 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -418,8 +418,7 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
BasicBlock::iterator BBI = &LI;
if (Value *AvailableVal = FindAvailableLoadedValue(Op, LI.getParent(), BBI,6))
return ReplaceInstUsesWith(
- LI, Builder->CreateBitOrPointerCast(AvailableVal, LI.getType(),
- LI.getName() + ".cast"));
+ LI, Builder->CreateBitCast(AvailableVal, LI.getType()));
// load(gep null, ...) -> unreachable
if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(Op)) {
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index c37a4c91c66..25a8b0cdbd3 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -902,8 +902,8 @@ bool JumpThreading::SimplifyPartiallyRedundantLoad(LoadInst *LI) {
// only happen in dead loops.
if (AvailableVal == LI) AvailableVal = UndefValue::get(LI->getType());
if (AvailableVal->getType() != LI->getType())
- AvailableVal =
- CastInst::CreateBitOrPointerCast(AvailableVal, LI->getType(), "", LI);
+ AvailableVal = CastInst::Create(CastInst::BitCast, AvailableVal,
+ LI->getType(), "", LI);
LI->replaceAllUsesWith(AvailableVal);
LI->eraseFromParent();
return true;
@@ -1040,8 +1040,8 @@ bool JumpThreading::SimplifyPartiallyRedundantLoad(LoadInst *LI) {
// predecessor use the same bitcast.
Value *&PredV = I->second;
if (PredV->getType() != LI->getType())
- PredV = CastInst::CreateBitOrPointerCast(PredV, LI->getType(), "",
- P->getTerminator());
+ PredV = CastInst::Create(CastInst::BitCast, PredV, LI->getType(), "",
+ P->getTerminator());
PN->addIncoming(PredV, I->first);
}
OpenPOWER on IntegriCloud