Skip to content

Commit

Permalink
[ConstantFold] Remove unnecessary checks in FoldBitCast() (NFCI)
Browse files Browse the repository at this point in the history
These are no-op casts, which are already handled earlier.
  • Loading branch information
nikic committed Nov 3, 2023
1 parent 2182561 commit c295d74
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions llvm/lib/IR/ConstantFold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit c295d74

Please sign in to comment.