diff options
author | Florian Hahn <flo@fhahn.com> | 2024-02-17 18:30:00 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2024-02-17 18:30:01 +0000 |
commit | 35ee6de966c36d095646b9b21fdd12eb45bdc9bf (patch) | |
tree | 48711feabd80205f981b2bafe1e40c6991651101 | |
parent | 715567d03771c437e26b16fbc71c30c4474b8895 (diff) |
[VPlan] Simplify addCanonicalIVRecipes by using VPBuilder (NFC).
Use VPBuilder to construct VPInstructions, which means there's no need
to manually inserting recipes.
-rw-r--r-- | llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 98b177cf5d2d..eca901fcdae4 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 |