[llvm-branch-commits] [llvm] c295d74 - [ConstantFold] Remove unnecessary checks in FoldBitCast() (NFCI)

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Nov 3 03:23:58 PDT 2023


Author: Nikita Popov
Date: 2023-11-03T11:08:08+01:00
New Revision: c295d7407ef3e4c42157406c7e99f258636c2c9a

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

LOG: [ConstantFold] Remove unnecessary checks in FoldBitCast() (NFCI)

These are no-op casts, which are already handled earlier.

Added: 
    

Modified: 
    llvm/lib/IR/ConstantFold.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index ada921bc2dea4db..4651767d0655a06 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -83,18 +83,8 @@ static Constant *FoldBitCast(Constant *V, Type *DestTy) {
     return nullptr;
   }
 
-  // Finally, implement bitcast folding now.   The code below doesn't handle
-  // bitcast right.
-  if (isa<ConstantPointerNull>(V))  // ptr->ptr cast.
-    return ConstantPointerNull::get(cast<PointerType>(DestTy));
-
   // Handle integral constant input.
   if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
-    if (DestTy->isIntegerTy())
-      // Integral -> Integral. This is a no-op because the bit widths must
-      // be the same. Consequently, we just fold to V.
-      return V;
-
     // See note below regarding the PPC_FP128 restriction.
     if (DestTy->isFloatingPointTy() && !DestTy->isPPC_FP128Ty())
       return ConstantFP::get(DestTy->getContext(),


        


More information about the llvm-branch-commits mailing list