[llvm] 17d276a - [TypePromotion] Avoid use of ConstantExpr::getZExt() (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 28 07:31:22 PDT 2023
Author: Nikita Popov
Date: 2023-09-28T16:19:08+02:00
New Revision: 17d276a6b8c9d9dce7d3317fe56fd3aa4987f0ea
URL: https://github.com/llvm/llvm-project/commit/17d276a6b8c9d9dce7d3317fe56fd3aa4987f0ea
DIFF: https://github.com/llvm/llvm-project/commit/17d276a6b8c9d9dce7d3317fe56fd3aa4987f0ea.diff
LOG: [TypePromotion] Avoid use of ConstantExpr::getZExt() (NFC)
Instead work on APInt.
Added:
Modified:
llvm/lib/CodeGen/TypePromotion.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp
index 426292345a1478a..51f77e5fd8b08af 100644
--- a/llvm/lib/CodeGen/TypePromotion.cpp
+++ b/llvm/lib/CodeGen/TypePromotion.cpp
@@ -492,11 +492,13 @@ void IRPromoter::PromoteTree() {
// SafeWrap because SafeWrap.size() is used elsewhere.
// For cmp, we need to sign extend a constant appearing in either
// operand. For add, we should only sign extend the RHS.
- Constant *NewConst = (SafeWrap.contains(I) &&
+ Constant *NewConst =
+ ConstantInt::get(Const->getContext(),
+ (SafeWrap.contains(I) &&
(I->getOpcode() == Instruction::ICmp || i == 1) &&
I->getOpcode() != Instruction::Sub)
- ? ConstantExpr::getSExt(Const, ExtTy)
- : ConstantExpr::getZExt(Const, ExtTy);
+ ? Const->getValue().sext(PromotedWidth)
+ : Const->getValue().zext(PromotedWidth));
I->setOperand(i, NewConst);
} else if (isa<UndefValue>(Op))
I->setOperand(i, ConstantInt::get(ExtTy, 0));
More information about the llvm-commits
mailing list