[llvm] 7990a7e - [IndVars] Use getSigned() in FP transform
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 06:04:41 PDT 2024
Author: Nikita Popov
Date: 2024-08-13T15:04:23+02:00
New Revision: 7990a7e58f0656f752178f22a767c6250b6aa8dc
URL: https://github.com/llvm/llvm-project/commit/7990a7e58f0656f752178f22a767c6250b6aa8dc
DIFF: https://github.com/llvm/llvm-project/commit/7990a7e58f0656f752178f22a767c6250b6aa8dc.diff
LOG: [IndVars] Use getSigned() in FP transform
This transform is working on signed integer, so this is the
logically correct API.
Split off from https://github.com/llvm/llvm-project/pull/80309.
Added:
Modified:
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index 3abf3aa5542c27..613597b0878814 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -357,19 +357,19 @@ bool IndVarSimplify::handleFloatingPointIV(Loop *L, PHINode *PN) {
// Insert new integer induction variable.
PHINode *NewPHI =
PHINode::Create(Int32Ty, 2, PN->getName() + ".int", PN->getIterator());
- NewPHI->addIncoming(ConstantInt::get(Int32Ty, InitValue),
+ NewPHI->addIncoming(ConstantInt::getSigned(Int32Ty, InitValue),
PN->getIncomingBlock(IncomingEdge));
NewPHI->setDebugLoc(PN->getDebugLoc());
- Instruction *NewAdd =
- BinaryOperator::CreateAdd(NewPHI, ConstantInt::get(Int32Ty, IncValue),
- Incr->getName() + ".int", Incr->getIterator());
+ Instruction *NewAdd = BinaryOperator::CreateAdd(
+ NewPHI, ConstantInt::getSigned(Int32Ty, IncValue),
+ Incr->getName() + ".int", Incr->getIterator());
NewAdd->setDebugLoc(Incr->getDebugLoc());
NewPHI->addIncoming(NewAdd, PN->getIncomingBlock(BackEdge));
- ICmpInst *NewCompare =
- new ICmpInst(TheBr->getIterator(), NewPred, NewAdd,
- ConstantInt::get(Int32Ty, ExitValue), Compare->getName());
+ ICmpInst *NewCompare = new ICmpInst(
+ TheBr->getIterator(), NewPred, NewAdd,
+ ConstantInt::getSigned(Int32Ty, ExitValue), Compare->getName());
NewCompare->setDebugLoc(Compare->getDebugLoc());
// In the following deletions, PN may become dead and may be deleted.
More information about the llvm-commits
mailing list