[llvm] 35ee6de - [VPlan] Simplify addCanonicalIVRecipes by using VPBuilder (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 17 10:30:08 PST 2024
Author: Florian Hahn
Date: 2024-02-17T18:30:01Z
New Revision: 35ee6de966c36d095646b9b21fdd12eb45bdc9bf
URL: https://github.com/llvm/llvm-project/commit/35ee6de966c36d095646b9b21fdd12eb45bdc9bf
DIFF: https://github.com/llvm/llvm-project/commit/35ee6de966c36d095646b9b21fdd12eb45bdc9bf.diff
LOG: [VPlan] Simplify addCanonicalIVRecipes by using VPBuilder (NFC).
Use VPBuilder to construct VPInstructions, which means there's no need
to manually inserting recipes.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 98b177cf5d2d0e..eca901fcdae4ce 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8510,21 +8510,16 @@ static void addCanonicalIVRecipes(VPlan &Plan, Type *IdxTy, bool HasNUW,
VPBasicBlock *Header = TopRegion->getEntryBasicBlock();
Header->insert(CanonicalIVPHI, Header->begin());
- // Add a CanonicalIVIncrement{NUW} VPInstruction to increment the scalar
- // IV by VF * UF.
- auto *CanonicalIVIncrement =
- new VPInstruction(Instruction::Add, {CanonicalIVPHI, &Plan.getVFxUF()},
- {HasNUW, false}, DL, "index.next");
+ VPBuilder Builder(TopRegion->getExitingBasicBlock());
+ // Add a VPInstruction to increment the scalar canonical IV by VF * UF.
+ auto *CanonicalIVIncrement = Builder.createOverflowingOp(
+ Instruction::Add, {CanonicalIVPHI, &Plan.getVFxUF()}, {HasNUW, false}, DL,
+ "index.next");
CanonicalIVPHI->addOperand(CanonicalIVIncrement);
- VPBasicBlock *EB = TopRegion->getExitingBasicBlock();
- EB->appendRecipe(CanonicalIVIncrement);
-
// Add the BranchOnCount VPInstruction to the latch.
- VPInstruction *BranchBack =
- new VPInstruction(VPInstruction::BranchOnCount,
- {CanonicalIVIncrement, &Plan.getVectorTripCount()}, DL);
- EB->appendRecipe(BranchBack);
+ Builder.createNaryOp(VPInstruction::BranchOnCount,
+ {CanonicalIVIncrement, &Plan.getVectorTripCount()}, DL);
}
// Add exit values to \p Plan. VPLiveOuts are added for each LCSSA phi in the
More information about the llvm-commits
mailing list