aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-11-03 11:41:14 +0100
committerNikita Popov <npopov@redhat.com>2023-11-03 11:41:14 +0100
commit01689175251f2624fb9d077666657aa21e3f7850 (patch)
tree86ec4cf761bc05197ee5448acf201274c33e2b7d /llvm/lib/IR/ConstantFold.cpp
parentd49a893cdbea0dd6f8fde7dc9f321b2e0d169bba (diff)
downloadllvm-01689175251f2624fb9d077666657aa21e3f7850.zip
llvm-01689175251f2624fb9d077666657aa21e3f7850.tar.gz
llvm-01689175251f2624fb9d077666657aa21e3f7850.tar.bz2
[ConstantFold] Remove redundant handling for casts of null (NFCI)
ConstantFoldCastInstruction() has generic handling for null values at the top. No need to repeat it for inttoptr and ptrtoint.
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index d51e9c6..91bb5b6 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -301,16 +301,6 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
return ConstantInt::get(FPC->getContext(), IntVal);
}
return nullptr; // Can't fold.
- case Instruction::IntToPtr: //always treated as unsigned
- if (V->isNullValue()) // Is it an integral null value?
- return ConstantPointerNull::get(cast<PointerType>(DestTy));
- return nullptr; // Other pointer types cannot be casted
- case Instruction::PtrToInt: // always treated as unsigned
- // Is it a null pointer value?
- if (V->isNullValue())
- return ConstantInt::get(DestTy, 0);
- // Other pointer types cannot be casted
- return nullptr;
case Instruction::UIToFP:
case Instruction::SIToFP:
if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
@@ -359,6 +349,8 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
case Instruction::BitCast:
return FoldBitCast(V, DestTy);
case Instruction::AddrSpaceCast:
+ case Instruction::IntToPtr:
+ case Instruction::PtrToInt:
return nullptr;
}
}