Skip to content

Commit a1e1c24

Browse files
committed
[ConstantFolding] Avoid use of ConstantExpr::getLShr() (NFC)
Work on APInt instead.
1 parent 3a98bf9 commit a1e1c24

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,11 @@ Constant *FoldBitCast(Constant *C, Type *DestTy, const DataLayout &DL) {
273273
for (unsigned j = 0; j != Ratio; ++j) {
274274
// Shift the piece of the value into the right place, depending on
275275
// endianness.
276-
Constant *Elt = ConstantExpr::getLShr(Src,
277-
ConstantInt::get(Src->getType(), ShiftAmt));
276+
APInt Elt = Src->getValue().lshr(ShiftAmt);
278277
ShiftAmt += isLittleEndian ? DstBitSize : -DstBitSize;
279278

280279
// Truncate and remember this piece.
281-
Result.push_back(ConstantExpr::getTrunc(Elt, DstEltTy));
280+
Result.push_back(ConstantInt::get(DstEltTy, Elt.trunc(DstBitSize)));
282281
}
283282
}
284283

0 commit comments

Comments
 (0)