Skip to content

Commit 17d276a

Browse files
committed
[TypePromotion] Avoid use of ConstantExpr::getZExt() (NFC)
Instead work on APInt.
1 parent 1b7285b commit 17d276a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

llvm/lib/CodeGen/TypePromotion.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,13 @@ void IRPromoter::PromoteTree() {
492492
// SafeWrap because SafeWrap.size() is used elsewhere.
493493
// For cmp, we need to sign extend a constant appearing in either
494494
// operand. For add, we should only sign extend the RHS.
495-
Constant *NewConst = (SafeWrap.contains(I) &&
495+
Constant *NewConst =
496+
ConstantInt::get(Const->getContext(),
497+
(SafeWrap.contains(I) &&
496498
(I->getOpcode() == Instruction::ICmp || i == 1) &&
497499
I->getOpcode() != Instruction::Sub)
498-
? ConstantExpr::getSExt(Const, ExtTy)
499-
: ConstantExpr::getZExt(Const, ExtTy);
500+
? Const->getValue().sext(PromotedWidth)
501+
: Const->getValue().zext(PromotedWidth));
500502
I->setOperand(i, NewConst);
501503
} else if (isa<UndefValue>(Op))
502504
I->setOperand(i, ConstantInt::get(ExtTy, 0));

0 commit comments

Comments
 (0)