[llvm] 7513650 - [ConstantFolding] Remove unnecessary pointer handling in FoldBitCast (NFCI)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 10 05:54:44 PST 2023
Author: Nikita Popov
Date: 2023-11-10T14:54:35+01:00
New Revision: 7513650be68bc087f280724415a00fef8b5bf898
URL: https://github.com/llvm/llvm-project/commit/7513650be68bc087f280724415a00fef8b5bf898
DIFF: https://github.com/llvm/llvm-project/commit/7513650be68bc087f280724415a00fef8b5bf898.diff
LOG: [ConstantFolding] Remove unnecessary pointer handling in FoldBitCast (NFCI)
The destination element type here cannot be a pointer type, as
this would require an inttoptr rather than bitcast.
Added:
Modified:
llvm/lib/Analysis/ConstantFolding.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 353cf733a428c04..ce43af8adc0bd95 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -277,15 +277,6 @@ Constant *FoldBitCast(Constant *C, Type *DestTy, const DataLayout &DL) {
ConstantInt::get(Src->getType(), ShiftAmt));
ShiftAmt += isLittleEndian ? DstBitSize : -DstBitSize;
- // Truncate the element to an integer with the same pointer size and
- // convert the element back to a pointer using a inttoptr.
- if (DstEltTy->isPointerTy()) {
- IntegerType *DstIntTy = Type::getIntNTy(C->getContext(), DstBitSize);
- Constant *CE = ConstantExpr::getTrunc(Elt, DstIntTy);
- Result.push_back(ConstantExpr::getIntToPtr(CE, DstEltTy));
- continue;
- }
-
// Truncate and remember this piece.
Result.push_back(ConstantExpr::getTrunc(Elt, DstEltTy));
}
More information about the llvm-commits
mailing list