LLVM 17.0.0git
VPlanTransforms.h
Go to the documentation of this file.
1//===- VPlanTransforms.h - Utility VPlan to VPlan transforms --------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file provides utility VPlan to VPlan transformations.
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
14#define LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
15
16#include "VPlan.h"
18
19namespace llvm {
20
21class InductionDescriptor;
22class Instruction;
23class PHINode;
24class ScalarEvolution;
25class Loop;
26class PredicatedScalarEvolution;
27class TargetLibraryInfo;
28class VPBuilder;
29class VPRecipeBuilder;
30
32 /// Replaces the VPInstructions in \p Plan with corresponding
33 /// widen recipes.
34 static void
37 GetIntOrFpInductionDescriptor,
38 SmallPtrSetImpl<Instruction *> &DeadInstructions,
39 ScalarEvolution &SE, const TargetLibraryInfo &TLI);
40
41 /// Wrap predicated VPReplicateRecipes with a mask operand in an if-then
42 /// region block and remove the mask operand. Optimize the created regions by
43 /// iteratively sinking scalar operands into the region, followed by merging
44 /// regions until no improvements are remaining.
46
47 /// Remove redundant VPBasicBlocks by merging them into their predecessor if
48 /// the predecessor has a single successor.
49 static bool mergeBlocksIntoPredecessors(VPlan &Plan);
50
51 /// Remove redundant casts of inductions.
52 ///
53 /// Such redundant casts are casts of induction variables that can be ignored,
54 /// because we already proved that the casted phi is equal to the uncasted phi
55 /// in the vectorized loop. There is no need to vectorize the cast - the same
56 /// value can be used for both the phi and casts in the vector loop.
57 static void removeRedundantInductionCasts(VPlan &Plan);
58
59 /// Try to replace VPWidenCanonicalIVRecipes with a widened canonical IV
60 /// recipe, if it exists.
61 static void removeRedundantCanonicalIVs(VPlan &Plan);
62
63 static void removeDeadRecipes(VPlan &Plan);
64
65 /// If any user of a VPWidenIntOrFpInductionRecipe needs scalar values,
66 /// provide them by building scalar steps off of the canonical scalar IV and
67 /// update the original IV's users. This is an optional optimization to reduce
68 /// the needs of vector extracts.
69 static void optimizeInductions(VPlan &Plan, ScalarEvolution &SE);
70
71 /// Remove redundant EpxandSCEVRecipes in \p Plan's entry block by replacing
72 /// them with already existing recipes expanding the same SCEV expression.
73 static void removeRedundantExpandSCEVRecipes(VPlan &Plan);
74
75 /// Sink users of fixed-order recurrences after the recipe defining their
76 /// previous value. Then introduce FirstOrderRecurrenceSplice VPInstructions
77 /// to combine the value from the recurrence phis and previous values. The
78 /// current implementation assumes all users can be sunk after the previous
79 /// value, which is enforced by earlier legality checks.
81
82 /// Optimize \p Plan based on \p BestVF and \p BestUF. This may restrict the
83 /// resulting plan to \p BestVF and \p BestUF.
84 static void optimizeForVFAndUF(VPlan &Plan, ElementCount BestVF,
85 unsigned BestUF,
87};
88
89} // namespace llvm
90
91#endif // LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
assume Assume Builder
This file contains the declarations of the Vectorization Plan base classes:
A struct for saving information about induction variables.
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
The main scalar evolution driver.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:344
Provides information about what library functions are available for the current target.
VPlan-based builder utility analogous to IRBuilder.
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition: VPlan.h:2177
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::unique_ptr< VPlan > VPlanPtr
Definition: VPlan.h:104
static void VPInstructionsToVPRecipes(VPlanPtr &Plan, function_ref< const InductionDescriptor *(PHINode *)> GetIntOrFpInductionDescriptor, SmallPtrSetImpl< Instruction * > &DeadInstructions, ScalarEvolution &SE, const TargetLibraryInfo &TLI)
Replaces the VPInstructions in Plan with corresponding widen recipes.
static void createAndOptimizeReplicateRegions(VPlan &Plan)
Wrap predicated VPReplicateRecipes with a mask operand in an if-then region block and remove the mask...
static void removeRedundantInductionCasts(VPlan &Plan)
Remove redundant casts of inductions.
static void adjustFixedOrderRecurrences(VPlan &Plan, VPBuilder &Builder)
Sink users of fixed-order recurrences after the recipe defining their previous value.
static void optimizeInductions(VPlan &Plan, ScalarEvolution &SE)
If any user of a VPWidenIntOrFpInductionRecipe needs scalar values, provide them by building scalar s...
static bool mergeBlocksIntoPredecessors(VPlan &Plan)
Remove redundant VPBasicBlocks by merging them into their predecessor if the predecessor has a single...
static void removeRedundantExpandSCEVRecipes(VPlan &Plan)
Remove redundant EpxandSCEVRecipes in Plan's entry block by replacing them with already existing reci...
static void removeRedundantCanonicalIVs(VPlan &Plan)
Try to replace VPWidenCanonicalIVRecipes with a widened canonical IV recipe, if it exists.
static void removeDeadRecipes(VPlan &Plan)
static void optimizeForVFAndUF(VPlan &Plan, ElementCount BestVF, unsigned BestUF, PredicatedScalarEvolution &PSE)
Optimize Plan based on BestVF and BestUF.