Skip to content

Commit 88771c4

Browse files
committed
[DSE] Simplify based on opaque pointers
Given the transition to opaque pointers we no longer need to emit some pointer casts. Int8PtrTy was set up to be a ptr in same address space a OrigDest, making the first CreatePointerCast dead. And then NewDestGEP will end up having the same type as OrigDest, making the second CreatePointerCast dead.
1 parent fba474d commit 88771c4

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -629,20 +629,11 @@ static bool tryToShorten(Instruction *DeadI, int64_t &DeadStart,
629629

630630
Value *OrigDest = DeadIntrinsic->getRawDest();
631631
if (!IsOverwriteEnd) {
632-
Type *Int8PtrTy =
633-
Type::getInt8PtrTy(DeadIntrinsic->getContext(),
634-
OrigDest->getType()->getPointerAddressSpace());
635-
Value *Dest = OrigDest;
636-
if (OrigDest->getType() != Int8PtrTy)
637-
Dest = CastInst::CreatePointerCast(OrigDest, Int8PtrTy, "", DeadI);
638632
Value *Indices[1] = {
639633
ConstantInt::get(DeadWriteLength->getType(), ToRemoveSize)};
640634
Instruction *NewDestGEP = GetElementPtrInst::CreateInBounds(
641-
Type::getInt8Ty(DeadIntrinsic->getContext()), Dest, Indices, "", DeadI);
635+
Type::getInt8Ty(DeadIntrinsic->getContext()), OrigDest, Indices, "", DeadI);
642636
NewDestGEP->setDebugLoc(DeadIntrinsic->getDebugLoc());
643-
if (NewDestGEP->getType() != OrigDest->getType())
644-
NewDestGEP = CastInst::CreatePointerCast(NewDestGEP, OrigDest->getType(),
645-
"", DeadI);
646637
DeadIntrinsic->setDest(NewDestGEP);
647638
}
648639

0 commit comments

Comments
 (0)