[llvm] 88771c4 - [DSE] Simplify based on opaque pointers

Bjorn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 18 13:17:35 PDT 2023


Author: Bjorn Pettersson
Date: 2023-09-18T22:17:10+02:00
New Revision: 88771c4181171436bac929cdd33207d244ec26f4

URL: https://github.com/llvm/llvm-project/commit/88771c4181171436bac929cdd33207d244ec26f4
DIFF: https://github.com/llvm/llvm-project/commit/88771c4181171436bac929cdd33207d244ec26f4.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index b6f9cb6cd2d0bb7..c81c1a0c3f57799 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -629,20 +629,11 @@ static bool tryToShorten(Instruction *DeadI, int64_t &DeadStart,
 
   Value *OrigDest = DeadIntrinsic->getRawDest();
   if (!IsOverwriteEnd) {
-    Type *Int8PtrTy =
-        Type::getInt8PtrTy(DeadIntrinsic->getContext(),
-                           OrigDest->getType()->getPointerAddressSpace());
-    Value *Dest = OrigDest;
-    if (OrigDest->getType() != Int8PtrTy)
-      Dest = CastInst::CreatePointerCast(OrigDest, Int8PtrTy, "", DeadI);
     Value *Indices[1] = {
         ConstantInt::get(DeadWriteLength->getType(), ToRemoveSize)};
     Instruction *NewDestGEP = GetElementPtrInst::CreateInBounds(
-        Type::getInt8Ty(DeadIntrinsic->getContext()), Dest, Indices, "", DeadI);
+        Type::getInt8Ty(DeadIntrinsic->getContext()), OrigDest, Indices, "", DeadI);
     NewDestGEP->setDebugLoc(DeadIntrinsic->getDebugLoc());
-    if (NewDestGEP->getType() != OrigDest->getType())
-      NewDestGEP = CastInst::CreatePointerCast(NewDestGEP, OrigDest->getType(),
-                                               "", DeadI);
     DeadIntrinsic->setDest(NewDestGEP);
   }
 


        


More information about the llvm-commits mailing list