[llvm] r187692 - Minor address space code simplification.
Matt Arsenault
Matthew.Arsenault at amd.com
Fri Aug 2 18:03:12 PDT 2013
Author: arsenm
Date: Fri Aug 2 20:03:12 2013
New Revision: 187692
URL: http://llvm.org/viewvc/llvm-project?rev=187692&view=rev
Log:
Minor address space code simplification.
Remove assertion that the verifier should catch.
Modified:
llvm/trunk/include/llvm/Transforms/Utils/Local.h
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=187692&r1=187691&r2=187692&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Fri Aug 2 20:03:12 2013
@@ -181,8 +181,7 @@ template<typename IRBuilderTy>
Value *EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &TD, User *GEP,
bool NoAssumptions = false) {
GEPOperator *GEPOp = cast<GEPOperator>(GEP);
- unsigned AS = GEPOp->getPointerAddressSpace();
- Type *IntPtrTy = TD.getIntPtrType(GEP->getContext(), AS);
+ Type *IntPtrTy = TD.getIntPtrType(GEP->getType());
Value *Result = Constant::getNullValue(IntPtrTy);
// If the GEP is inbounds, we know that none of the addressing operations will
@@ -190,7 +189,7 @@ Value *EmitGEPOffset(IRBuilderTy *Builde
bool isInBounds = GEPOp->isInBounds() && !NoAssumptions;
// Build a mask for high order bits.
- unsigned IntPtrWidth = TD.getPointerSizeInBits(AS);
+ unsigned IntPtrWidth = IntPtrTy->getScalarType()->getIntegerBitWidth();
uint64_t PtrSizeMask = ~0ULL >> (64 - IntPtrWidth);
gep_type_iterator GTI = gep_type_begin(GEP);
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=187692&r1=187691&r2=187692&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Fri Aug 2 20:03:12 2013
@@ -676,9 +676,8 @@ static Constant *stripAndComputeConstant
if (!TD)
return ConstantInt::get(IntegerType::get(V->getContext(), 64), 0);
- unsigned AS = V->getType()->getPointerAddressSpace();
- unsigned IntPtrWidth = TD->getPointerSizeInBits(AS);
- APInt Offset = APInt::getNullValue(IntPtrWidth);
+ Type *IntPtrTy = TD->getIntPtrType(V->getType())->getScalarType();
+ APInt Offset = APInt::getNullValue(IntPtrTy->getIntegerBitWidth());
// Even though we don't look through PHI nodes, we could be called on an
// instruction in an unreachable block, which may be on a cycle.
@@ -690,11 +689,7 @@ static Constant *stripAndComputeConstant
break;
V = GEP->getPointerOperand();
} else if (Operator::getOpcode(V) == Instruction::BitCast) {
- Value *Op0 = cast<Operator>(V)->getOperand(0);
- assert(TD->getPointerTypeSizeInBits(V->getType()) ==
- TD->getPointerTypeSizeInBits(Op0->getType()) &&
- "Bitcasting between pointers from different size address spaces");
- V = Op0;
+ V = cast<Operator>(V)->getOperand(0);
} else if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) {
if (GA->mayBeOverridden())
break;
@@ -706,7 +701,6 @@ static Constant *stripAndComputeConstant
"Unexpected operand type!");
} while (Visited.insert(V));
- Type *IntPtrTy = TD->getIntPtrType(V->getContext(), AS);
Constant *OffsetIntPtr = ConstantInt::get(IntPtrTy, Offset);
if (V->getType()->isVectorTy())
return ConstantVector::getSplat(V->getType()->getVectorNumElements(),
More information about the llvm-commits
mailing list