[llvm] bbc8079 - [SCEV] Remove unnecessary bitcast (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 9 07:22:19 PDT 2023


Author: Nikita Popov
Date: 2023-08-09T16:21:54+02:00
New Revision: bbc807990660377caa38e5bd183b57d465541239

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

LOG: [SCEV] Remove unnecessary bitcast (NFC)

Added: 
    

Modified: 
    llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 98add83ddbc8dd..234b6fe438da88 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -9654,12 +9654,9 @@ static Constant *BuildConstantFromSCEV(const SCEV *V) {
       }
       assert(!C->getType()->isPointerTy() &&
              "Can only have one pointer, and it must be last");
-      if (auto *PT = dyn_cast<PointerType>(OpC->getType())) {
-        // The offsets have been converted to bytes.  We can add bytes to an
-        // i8* by GEP with the byte count in the first index.
-        Type *DestPtrTy =
-            Type::getInt8PtrTy(PT->getContext(), PT->getAddressSpace());
-        OpC = ConstantExpr::getBitCast(OpC, DestPtrTy);
+      if (OpC->getType()->isPointerTy()) {
+        // The offsets have been converted to bytes.  We can add bytes using
+        // an i8 GEP.
         C = ConstantExpr::getGetElementPtr(Type::getInt8Ty(C->getContext()),
                                            OpC, C);
       } else {


        


More information about the llvm-commits mailing list