diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-09 13:28:42 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2023-12-09 13:28:42 +0000 |
| commit | b1c73532ee8997fe5dfbeb7d223027bdf99758a0 (patch) | |
| tree | 7d6e51c294ab6719475d660217aa0c0ad0526292 /llvm/lib/CodeGen/TypePromotion.cpp | |
| parent | 7fa27ce4a07f19b07799a767fc29416f3b625afb (diff) | |
Diffstat (limited to 'llvm/lib/CodeGen/TypePromotion.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/TypePromotion.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp index 426292345a14..053caf518bd1 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)); @@ -1014,11 +1016,8 @@ bool TypePromotionLegacy::runOnFunction(Function &F) { if (skipFunction(F)) return false; - auto *TPC = getAnalysisIfAvailable<TargetPassConfig>(); - if (!TPC) - return false; - - auto *TM = &TPC->getTM<TargetMachine>(); + auto &TPC = getAnalysis<TargetPassConfig>(); + auto *TM = &TPC.getTM<TargetMachine>(); auto &TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F); auto &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo(); |
