[llvm] a1e1c24 - [ConstantFolding] Avoid use of ConstantExpr::getLShr() (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 10 06:06:25 PST 2023
Author: Nikita Popov
Date: 2023-11-10T15:06:18+01:00
New Revision: a1e1c24331b7b67ae59a880d263620c614cdb918
URL: https://github.com/llvm/llvm-project/commit/a1e1c24331b7b67ae59a880d263620c614cdb918
DIFF: https://github.com/llvm/llvm-project/commit/a1e1c24331b7b67ae59a880d263620c614cdb918.diff
LOG: [ConstantFolding] Avoid use of ConstantExpr::getLShr() (NFC)
Work on APInt instead.
Added:
Modified:
llvm/lib/Analysis/ConstantFolding.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index ce43af8adc0bd95..966a65ac26b8017 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -273,12 +273,11 @@ Constant *FoldBitCast(Constant *C, Type *DestTy, const DataLayout &DL) {
for (unsigned j = 0; j != Ratio; ++j) {
// Shift the piece of the value into the right place, depending on
// endianness.
- Constant *Elt = ConstantExpr::getLShr(Src,
- ConstantInt::get(Src->getType(), ShiftAmt));
+ APInt Elt = Src->getValue().lshr(ShiftAmt);
ShiftAmt += isLittleEndian ? DstBitSize : -DstBitSize;
// Truncate and remember this piece.
- Result.push_back(ConstantExpr::getTrunc(Elt, DstEltTy));
+ Result.push_back(ConstantInt::get(DstEltTy, Elt.trunc(DstBitSize)));
}
}
More information about the llvm-commits
mailing list